strace: Fix Coverity issues
CID 66964: Don't trust environment variable without length check CID 66968: Add missing va_end Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
		| @@ -88,6 +88,7 @@ warn (int geterrno, const char *fmt, ...) | |||||||
|       fputs (buf, stderr); |       fputs (buf, stderr); | ||||||
|       fputs ("\n", stderr); |       fputs ("\n", stderr); | ||||||
|     } |     } | ||||||
|  |   va_end (args); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void __attribute__ ((noreturn)) | static void __attribute__ ((noreturn)) | ||||||
| @@ -351,13 +352,16 @@ create_child (char **argv) | |||||||
|   make_command_line (one_line, argv); |   make_command_line (one_line, argv); | ||||||
|  |  | ||||||
|   SetConsoleCtrlHandler (NULL, 0); |   SetConsoleCtrlHandler (NULL, 0); | ||||||
|  |  | ||||||
|   const char *cygwin_env = getenv ("CYGWIN"); |   const char *cygwin_env = getenv ("CYGWIN"); | ||||||
|   const char *space; |   const char *space; | ||||||
|   if (cygwin_env) |  | ||||||
|  |   if (cygwin_env && strlen (cygwin_env) <= 256) /* sanity check */ | ||||||
|     space = " "; |     space = " "; | ||||||
|   else |   else | ||||||
|     space = cygwin_env = ""; |     space = cygwin_env = ""; | ||||||
|   char *newenv = (char *) malloc (sizeof ("CYGWIN=noglob") + strlen (space) + strlen (cygwin_env)); |   char *newenv = (char *) malloc (sizeof ("CYGWIN=noglob") | ||||||
|  | 				  + strlen (space) + strlen (cygwin_env)); | ||||||
|   sprintf (newenv, "CYGWIN=noglob%s%s", space, cygwin_env); |   sprintf (newenv, "CYGWIN=noglob%s%s", space, cygwin_env); | ||||||
|   _putenv (newenv); |   _putenv (newenv); | ||||||
|   ret = CreateProcess (0, one_line.buf,	/* command line */ |   ret = CreateProcess (0, one_line.buf,	/* command line */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user