From b22f312a99b3e55f902a70190a4b2a57207aa44a Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 18 Sep 2015 08:49:27 +0200 Subject: [PATCH] Fix segfault in open_bpipe() when the program is empty --- bacula/src/lib/bpipe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bacula/src/lib/bpipe.c b/bacula/src/lib/bpipe.c index 81d673fd69..c0ef83a633 100644 --- a/bacula/src/lib/bpipe.c +++ b/bacula/src/lib/bpipe.c @@ -74,6 +74,12 @@ BPIPE *open_bpipe(char *prog, int wait, const char *mode, char *envp[]) BPIPE *bpipe; int save_errno; + if (!prog || !*prog) { + /* execve(3) A component of the file does not name an existing file or file is an empty string. */ + errno = ENOENT; + return NULL; + } + bpipe = (BPIPE *)malloc(sizeof(BPIPE)); memset(bpipe, 0, sizeof(BPIPE)); mode_read = (mode[0] == 'r'); -- 2.39.5