Skip to content

Commit

Permalink
Error cases when parsing commands into argv are not handled sufficiently
Browse files Browse the repository at this point in the history
  • Loading branch information
m90 committed Dec 13, 2024
1 parent 2685571 commit e5f5d0b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/backup/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ import (
)

func (s *script) exec(containerRef string, command string, user string) ([]byte, []byte, error) {
args, _ := argv.Argv(command, nil, nil)
args, err := argv.Argv(command, nil, nil)
if err != nil {
return nil, nil, errwrap.Wrap(err, fmt.Sprintf("error parsing argv from '%s'", command))
}
if len(args) == 0 {
return nil, nil, errwrap.Wrap(nil, "received unexpected empty command")
}

commandEnv := []string{
fmt.Sprintf("COMMAND_RUNTIME_ARCHIVE_FILEPATH=%s", s.file),
}

execID, err := s.cli.ContainerExecCreate(context.Background(), containerRef, container.ExecOptions{
Cmd: args[0],
AttachStdin: true,
Expand Down

0 comments on commit e5f5d0b

Please sign in to comment.