[PATCH] stdlib: Perform NULL pointer check for the getenv argument
Dennis Brendel
dbrendel@redhat.com
Tue Jun 13 07:01:38 GMT 2023
On 6/12/23 23:30, Sam James wrote:
>
> Dennis Brendel via Libc-alpha <libc-alpha@sourceware.org> writes:
>
>> 'name' is just de-referenced without checking for it being non-NULL.
>> Passing NULL is not something one should do in the first place, but
>> returning NULL seems to be reasonable in that case instead of just
>> waiting for the segfault that might or might not be handled.
>>
>> This adds another barrier for e.g. safety applications.
>>
>
> See Carlos' email for why we can't do this, but I'm wondering what the
> motivation here was and if we can do something to help with that?
Maybe to sum it up as some overambitious activity of myself is not too
far off :-D
The motivation is to make using glibc as "safe" as possible upstream as
part of Red Hat's In-Vehicle Operating System effort.
In this specific case I think we are good, since the function prototype,
as Carlos pointed out, already specifies the use of getenv() and has the
corresponding function attribute set.
More information about the Libc-alpha
mailing list