Skip to content

Commit 95ce74f

Browse files
committed
Return nil from parseCommand on empty input and fail fast in exec
1 parent ef8dfeb commit 95ce74f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ func parseCommand(cmd string) []string {
541541
}
542542
p.flush()
543543
if len(p.args) == 0 {
544-
return []string{cmd}
544+
return nil
545545
}
546546
return p.args
547547
}
@@ -559,6 +559,9 @@ func (r *TestRunner) exec(cmd string) (int, string, error) {
559559
// Parse command string safely to avoid command injection
560560
// This prevents shell interpretation of the command string
561561
cmdArgs := parseCommand(cmd)
562+
if len(cmdArgs) == 0 {
563+
return -1, "", fmt.Errorf("empty command")
564+
}
562565

563566
execID, err := r.cli.ContainerExecCreate(r.ctx, r.containerID, container.ExecOptions{
564567
Cmd: cmdArgs,

0 commit comments

Comments
 (0)