This is the mail archive of the
mailing list for the glibc project.
Re: [RFC] Make getenv O(1)
- From: Florian Weimer <fweimer at redhat dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>, Rich Felker <dalias at aerifal dot cx>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 18 Oct 2013 13:45:36 +0200
- Subject: Re: [RFC] Make getenv O(1)
- Authentication-results: sourceware.org; auth=none
- References: <20131014155229 dot GA25159 at domone dot podge> <20131014165411 dot GZ20515 at brightrain dot aerifal dot cx> <20131014172852 dot GA26005 at domone dot podge>
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