diff options
| author | sctemme <sctemme@13f79535-47bb-0310-9956-ffa450edef68> | 2011-11-07 18:29:46 +0000 |
|---|---|---|
| committer | sctemme <sctemme@13f79535-47bb-0310-9956-ffa450edef68> | 2011-11-07 18:29:46 +0000 |
| commit | 4e44d084ac3c6fc2f7a50b555aab05aa89125464 (patch) | |
| tree | 4197f814638b31bd8cbaea61c1a1cb15ccd3a743 | |
| parent | 9e498d4c61e3fe8c0a378a91641a35259bb787fd (diff) | |
| download | libapr-4e44d084ac3c6fc2f7a50b555aab05aa89125464.tar.gz | |
Clarify what happens to the proc structure used by apr_fork().
Set the proc->pid field to the pid of the newly created child.
Note that a mere pid value provides little entropy to mix into
the child random pool.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1198860 13f79535-47bb-0310-9956-ffa450edef68
| -rw-r--r-- | random/unix/apr_random.c | 5 | ||||
| -rw-r--r-- | threadproc/unix/proc.c | 10 |
2 files changed, 8 insertions, 7 deletions
diff --git a/random/unix/apr_random.c b/random/unix/apr_random.c index c6d671c6b..852cfd6e3 100644 --- a/random/unix/apr_random.c +++ b/random/unix/apr_random.c @@ -159,6 +159,11 @@ APR_DECLARE(void) apr_random_after_fork(apr_proc_t *proc) apr_random_t *r; for (r = all_random; r; r = r->next) + /* + * XXX Note: the pid does not provide sufficient entropy to + * actually call this secure. See Ben's paper referenced at + * the top of this file. + */ mixer(r,proc->pid); } diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c index 8ded39177..004772ff8 100644 --- a/threadproc/unix/proc.c +++ b/threadproc/unix/proc.c @@ -219,15 +219,14 @@ APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) { int pid; + + memset(proc, 0, sizeof(apr_proc_t)); if ((pid = fork()) < 0) { return errno; } else if (pid == 0) { - proc->pid = pid; - proc->in = NULL; - proc->out = NULL; - proc->err = NULL; + proc->pid = getpid(); apr_random_after_fork(proc); @@ -235,9 +234,6 @@ APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool) } proc->pid = pid; - proc->in = NULL; - proc->out = NULL; - proc->err = NULL; return APR_INPARENT; } |
