]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 49116] Check potential null pointer dereference.
authorPaul Smith <psmith@gnu.org>
Sun, 18 Dec 2016 15:22:43 +0000 (10:22 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 25 Dec 2016 23:18:45 +0000 (18:18 -0500)
* w32/subproc/sub_proc.c (make_command_line): Simplify cygwin shell
check for correctness.

w32/subproc/sub_proc.c

index af15dbc630aefd05d557bcd5a5f5e8031d58083f..69b3ae1351c2994017bb15e77eb3cf5a9784bcbf 100644 (file)
@@ -1195,7 +1195,7 @@ process_cleanup(
  *
  * Returns:  the buffer or NULL for failure
  *      Shell case:  sh_name a:/full/path/to/script argv[1] argv[2] ...
- *  Otherwise:   argv[0] argv[1] argv[2] ...
+ *      Otherwise:   argv[0] argv[1] argv[2] ...
  *
  * Notes/Dependencies:
  *   CreateProcess does not take an argv, so this command creates a
@@ -1212,15 +1212,15 @@ make_command_line( char *shell_name, char *full_exec_path, char **argv)
         unsigned int    bytes_required = 0;
         char*           command_line;
         char*           command_line_i;
-        int  cygwin_mode = 0; /* HAVE_CYGWIN_SHELL */
         int have_sh = 0; /* HAVE_CYGWIN_SHELL */
+        int cygwin_mode = 0; /* HAVE_CYGWIN_SHELL */
 
 #ifdef HAVE_CYGWIN_SHELL
-        have_sh = (shell_name != NULL || strstr(full_exec_path, "sh.exe"));
         cygwin_mode = 1;
 #endif
 
         if (shell_name && full_exec_path) {
+                have_sh = cygwin_mode && strstr(full_exec_path, "sh.exe");
                 bytes_required
                   = strlen(shell_name) + 1 + strlen(full_exec_path);
                 /*