From 15bb95ccc328d9b7ee59b3f2c7e1cd9f02c2435c Mon Sep 17 00:00:00 2001 From: kaddy-tom <71744781+kaddy-tom@users.noreply.github.com> Date: Fri, 10 Dec 2021 20:52:05 +1100 Subject: [PATCH] terminal/command: fix up OoB in `deferred` command (#2823) Prior to this, sending a `deferred` command with no arguments would immediately crash the debug session. --- pkg/terminal/command.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/terminal/command.go b/pkg/terminal/command.go index 7f5fd08f..272f6071 100644 --- a/pkg/terminal/command.go +++ b/pkg/terminal/command.go @@ -951,7 +951,10 @@ func (c *Commands) frameCommand(t *Term, ctx callContext, argstr string, directi func (c *Commands) deferredCommand(t *Term, ctx callContext, argstr string) error { ctx.Prefix = deferredPrefix - space := strings.Index(argstr, " ") + space := strings.IndexRune(argstr, ' ') + if space < 0 { + return errors.New("not enough arguments") + } var err error ctx.Scope.DeferredCall, err = strconv.Atoi(argstr[:space])