fielding 99/03/07 05:51:20
Modified: src/ap ap_execve.c Log: Added error messages for malloc calls. Submitted by: John Bley <[EMAIL PROTECTED]> Reviewed by: Roy Fielding Revision Changes Path 1.12 +10 -2 apache-1.3/src/ap/ap_execve.c Index: ap_execve.c =================================================================== RCS file: /home/cvs/apache-1.3/src/ap/ap_execve.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ap_execve.c 1999/01/01 19:04:36 1.11 +++ ap_execve.c 1999/03/07 13:51:19 1.12 @@ -126,8 +126,10 @@ } va_end(adummy); - if ((argv = (char **) malloc((argc + 2) * sizeof(*argv))) == NULL) + if ((argv = (char **) malloc((argc + 2) * sizeof(*argv))) == NULL) { + fprintf(stderr, "Ouch! Out of memory in ap_execle()!\n"); return -1; + } /* Pass two --- copy the argument strings into the result space */ va_start(adummy, argv0); @@ -222,8 +224,10 @@ else { int i = count_args(argv) + 1; /* +1 for leading SHELL_PATH */ - if ((script_argv = malloc(sizeof(*script_argv) * i)) == NULL) + if ((script_argv = malloc(sizeof(*script_argv) * i)) == NULL) { + fprintf(stderr, "Ouch! Out of memory in ap_execve()!\n"); return -1; + } script_argv[0] = SHELL_PATH; @@ -345,6 +349,10 @@ newargv = (char **) malloc((p - lbuf + 1) + (i + sargc + 1) * sizeof(*newargv)); + if (newargv == NULL) { + fprintf(stderr, "Ouch! Out of memory in hashbang()!\n"); + return NULL; + } ws = &((char *) newargv)[(i + sargc + 1) * sizeof(*newargv)]; /* Copy entries to allocated memory */