[RFC] Make getenv O(1)

Florian Weimer fweimer@redhat.com
Fri Oct 18 11:46:00 GMT 2013


On 10/14/2013 07:28 PM, Ondřej Bílka wrote:

>> In general it's impossible to use anything but linear search because
>> the application can modify environ[] directly (although it's
>> questionable whether this is permissible by the standard)

> Linear search applies only when environment variable is not present.
> When it is present then getting its index in environ and checking that
> it matches should be O(1).

Couldn't an earlier entry shadow the entry at the index?

I think we should aim for a totally different API that also fixes the 
races/memory leaks instead of tweaking the existing implementation. 
Unfortunately, the "secure" API in C11 doesn't address our issues.

-- 
Florian Weimer / Red Hat Product Security Team



More information about the Libc-alpha mailing list