[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] progname: don't segfault when argv is NULL
From: |
Jim Meyering |
Subject: |
Re: [PATCH] progname: don't segfault when argv is NULL |
Date: |
Wed, 09 Dec 2009 18:09:20 +0100 |
Bruno Haible wrote:
>> perhaps incomplete, since you can make the same argument about the "envp"
>> pointer.
>
> How so?
>From the perspective that since POSIX disallows passing a NULL
pointer, it would make sense to label each corresponding parameter
with the nonnull attribute.
Not a big deal, though, since we're just trying to avoid abuse.
> When the caller passes a NULL envp argument - which POSIX does not
> allow - the kernel provides an empty environment array instead. The callee
> never sees a NULL 'environ'.
>
> POSIX refers to argv[0], but not to envp[0].
The POSIX spec for execve says this about envp:
The argument envp is an array of character pointers to null-terminated
strings. These strings shall constitute the environment for the new
process image. The envp array is terminated by a null pointer.
which I seem to recall means (probably due to the definition of "array of
strings") that it must be non-NULL.
> It also contains language that explicitly says the callee is not guaranteed
> to be
> invoked with a POSIX compliant 'environ':
> "The new process might be invoked in a non-conforming environment if the
> envp array does not contain implementation-defined variables required
> by the implementation to provide a conforming environment. See the
> _CS_V7_ENV entry in <unistd.h> and confstr() for details."
- Re: [PATCH] progname: don't segfault when argv is NULL, (continued)
- Re: [PATCH] progname: don't segfault when argv is NULL, Jim Meyering, 2009/12/05
- Re: [PATCH] progname: don't segfault when argv is NULL, Jim Meyering, 2009/12/06
- __nonnull__ declarations, Bruno Haible, 2009/12/06
- Re: __nonnull__ declarations, Jim Meyering, 2009/12/07
- Re: __nonnull__ declarations, Bruno Haible, 2009/12/10
- Re: [PATCH] progname: don't segfault when argv is NULL, Bruno Haible, 2009/12/06
- Re: [PATCH] progname: don't segfault when argv is NULL,
Jim Meyering <=
- Re: [PATCH] progname: don't segfault when argv is NULL, Bruno Haible, 2009/12/09
- Re: [PATCH] progname: don't segfault when argv is NULL, Bruno Haible, 2009/12/09
- Re: [PATCH] progname: don't segfault when argv is NULL, Jim Meyering, 2009/12/09