From 6a1c04e803ae19c19a82d69ee218e01ca01c7ab9 Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Tue, 25 Dec 2012 20:54:47 +0000 Subject: [PATCH] Exit with error message if out of mem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1425772 13f79535-47bb-0310-9956-ffa450edef68 --- support/suexec.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/support/suexec.c b/support/suexec.c index 5b6b254cc8..32e73202a4 100644 --- a/support/suexec.c +++ b/support/suexec.c @@ -241,11 +241,15 @@ static void clean_env(void) if ((cleanenv = (char **) calloc(AP_ENVBUF, sizeof(char *))) == NULL) { log_err("failed to malloc memory for environment\n"); - exit(120); + exit(123); } sprintf(pathbuf, "PATH=%s", AP_SAFE_PATH); cleanenv[cidx] = strdup(pathbuf); + if (cleanenv[cidx] == NULL) { + log_err("failed to malloc memory for environment\n"); + exit(124); + } cidx++; for (ep = envp; *ep && cidx < AP_ENVBUF-1; ep++) { @@ -422,7 +426,10 @@ int main(int argc, char *argv[]) } } gid = gr->gr_gid; - actual_gname = strdup(gr->gr_name); + if ((actual_gname = strdup(gr->gr_name)) == NULL) { + log_err("failed to alloc memory\n"); + exit(125); + } #ifdef _OSD_POSIX /* @@ -457,6 +464,10 @@ int main(int argc, char *argv[]) uid = pw->pw_uid; actual_uname = strdup(pw->pw_name); target_homedir = strdup(pw->pw_dir); + if (actual_uname == NULL || target_homedir == NULL) { + log_err("failed to alloc memory\n"); + exit(126); + } /* * Log the transaction here to be sure we have an open log -- 2.40.0