diff options
author | Stefan Fritsch <sf@apache.org> | 2010-07-27 22:09:45 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@apache.org> | 2010-07-27 22:09:45 +0000 |
commit | 443247b17081cb00b0e7f2f688889417cb45871f (patch) | |
tree | 1cb6ddc24a0845e85f254eec9056103e26b73d0b /threadproc/unix | |
parent | 473c87316e7cf23eadb438189d2932b86ac8afae (diff) | |
download | apr-443247b17081cb00b0e7f2f688889417cb45871f.tar.gz apr-443247b17081cb00b0e7f2f688889417cb45871f.zip |
Fix various issues found by cppcheck
- error handling issues
- use of uninitialized data
- null pointer dereference
- unused variables
- memory/fd leaks
- broken code in threadproc/beos/proc.c
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@979891 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc/unix')
-rw-r--r-- | threadproc/unix/proc.c | 7 | ||||
-rw-r--r-- | threadproc/unix/procsup.c | 4 |
2 files changed, 5 insertions, 6 deletions
diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c index b9a674b7f..8deb6de2f 100644 --- a/threadproc/unix/proc.c +++ b/threadproc/unix/proc.c @@ -396,7 +396,6 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, return errno; } else if (new->pid == 0) { - int status; /* child process */ /* @@ -478,7 +477,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, } /* Only try to switch if we are running as root */ if (attr->gid != -1 && !geteuid()) { - if ((status = setgid(attr->gid))) { + if (setgid(attr->gid)) { if (attr->errfn) { attr->errfn(pool, errno, "setting of group failed"); } @@ -487,7 +486,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, } if (attr->uid != -1 && !geteuid()) { - if ((status = setuid(attr->uid))) { + if (setuid(attr->uid)) { if (attr->errfn) { attr->errfn(pool, errno, "setting of user failed"); } @@ -495,7 +494,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, } } - if ((status = limit_proc(attr)) != APR_SUCCESS) { + if (limit_proc(attr) != APR_SUCCESS) { if (attr->errfn) { attr->errfn(pool, errno, "setting of resource limits failed"); } diff --git a/threadproc/unix/procsup.c b/threadproc/unix/procsup.c index 376baf21f..94177f92a 100644 --- a/threadproc/unix/procsup.c +++ b/threadproc/unix/procsup.c @@ -18,8 +18,6 @@ APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize) { - int x; - if (chdir("/") == -1) { return errno; } @@ -28,6 +26,8 @@ APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize) /* Don't detach for MPE because child processes can't survive the death of * the parent. */ if (daemonize) { + int x; + if ((x = fork()) > 0) { exit(0); } |