You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Jeff Trawick <tr...@gmail.com> on 2005/10/09 14:04:55 UTC

[PATCH] apr_proc_create() and NULL pointer for env and Purify

With an APR app, NULL is passed for the environment to execve() when
NULL is passed for the env ptr and cmdtype is APR_SHELLCMD or
APR_PROGRAM.

When NULL is passed for the environment to execve(), Purify gets upset
and the new child crashes.  I haven't seen an execve() which get upset
(but see unresolved PR #25103), but maybe Purify knows something APR
doesn't.  Or maybe it is just a Purify bug (seen on Solaris and
Linux).

The patch is against the 0.9.x branch, but the same change is
applicable to the other branches.

Any concerns about the attached patch?   Just make the app change if
it needs to be tested with Purify and leave APR alone?

Re: [PATCH] apr_proc_create() and NULL pointer for env and Purify

Posted by Joe Orton <jo...@redhat.com>.
On Sun, Oct 09, 2005 at 08:04:55AM -0400, Jeff Trawick wrote:
> Any concerns about the attached patch?   Just make the app change if
> it needs to be tested with Purify and leave APR alone?

I think it's correct to fix this in APR, any standard I read requires 
that envp is a NULL-terminated array of char *pointers, which current 
APR behaviour does not satisfy.  +1 to the patch

> Index: threadproc/unix/proc.c
> ===================================================================
> --- threadproc/unix/proc.c	(revision 307403)
> +++ threadproc/unix/proc.c	(working copy)
> @@ -292,7 +292,12 @@
>                                            apr_pool_t *pool)
>  {
>      int i;
> +    const char * const empty_envp[] = {NULL};
>  
> +    if (!env) { /* Purify doesn't like NULL passed to execve() */
> +        env = empty_envp;
> +    }
> +
>      new->in = attr->parent_in;
>      new->err = attr->parent_err;
>      new->out = attr->parent_out;
>