summaryrefslogtreecommitdiffstats
path: root/support/suexec.c
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2012-12-25 21:54:47 +0100
committerStefan Fritsch <sf@apache.org>2012-12-25 21:54:47 +0100
commit6a1c04e803ae19c19a82d69ee218e01ca01c7ab9 (patch)
treebaa61e12d372569140f9869c2d47963cd3db28f8 /support/suexec.c
parentReplace strdup by ap_malloc to ensure a proper error message if out-of-memory. (diff)
downloadapache2-6a1c04e803ae19c19a82d69ee218e01ca01c7ab9.tar.xz
apache2-6a1c04e803ae19c19a82d69ee218e01ca01c7ab9.zip
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
Diffstat (limited to 'support/suexec.c')
-rw-r--r--support/suexec.c15
1 files 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