s3: in sys_popen(), validate input before opening the pipe.
authorMichael Adam <obnox@samba.org>
Tue, 4 Sep 2012 13:15:42 +0000 (15:15 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 4 Sep 2012 18:39:20 +0000 (20:39 +0200)
source3/lib/system.c

index 8c9c05f4de0fd7fd933dbb132e49704eef336b7f..ce55e83d583009f20e6f98d136dbfe75a68c10d6 100644 (file)
@@ -1161,17 +1161,17 @@ int sys_popen(const char *command)
        char **argl = NULL;
        int ret;
 
+       if (!*command) {
+               errno = EINVAL;
+               return -1;
+       }
+
        if (pipe(pipe_fds) < 0)
                return -1;
 
        parent_end = pipe_fds[0];
        child_end = pipe_fds[1];
 
-       if (!*command) {
-               errno = EINVAL;
-               goto err_exit;
-       }
-
        if((entry = SMB_MALLOC_P(popen_list)) == NULL)
                goto err_exit;