From e5f5d0bc97fc65847d49fcc9b328daf3f1acabff Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Fri, 13 Dec 2024 13:13:42 +0100 Subject: [PATCH] Error cases when parsing commands into argv are not handled sufficiently --- cmd/backup/exec.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/backup/exec.go b/cmd/backup/exec.go index 0dac44e..b329e57 100644 --- a/cmd/backup/exec.go +++ b/cmd/backup/exec.go @@ -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,