Re: [PATCH 0/6] getenv() timing fixes

2019-01-15 Thread Junio C Hamano
Jeff King writes: > So actually, that's pretty easy to do without writing much code at all. > Something like: > > #define xgetenv(name) strintern(getenv(name)) > > It means we're effectively storing the environment twice in the worst > case, but that's probably not a big deal. Unless we have a

Re: [PATCH 0/6] getenv() timing fixes

2019-01-15 Thread Jeff King
On Tue, Jan 15, 2019 at 02:41:42PM -0500, Jeff King wrote: > The more involved one (that doesn't pass along memory ownership) is > something like: > > static struct hashmap env_cache; > > const char *getenv_safe(const char *name) > { > > if (e = hashmap_get(&env_cache, name)) >

Re: [PATCH 0/6] getenv() timing fixes

2019-01-15 Thread Jeff King
On Tue, Jan 15, 2019 at 11:32:56AM -0800, Junio C Hamano wrote: > Jeff King writes: > > > On Sat, Jan 12, 2019 at 10:51:42AM -0800, Stefan Beller wrote: > > > >> > I wonder, and not as "you should do this" feedback on this series, just > >> > >> There is a getenv_safe() in environment.c, but I

Re: [PATCH 0/6] getenv() timing fixes

2019-01-15 Thread Stefan Beller
On Tue, Jan 15, 2019 at 11:32 AM Junio C Hamano wrote: > > Jeff King writes: > > > On Sat, Jan 12, 2019 at 10:51:42AM -0800, Stefan Beller wrote: > > > >> > I wonder, and not as "you should do this" feedback on this series, just > >> > >> There is a getenv_safe() in environment.c, but I guess a x

Re: [PATCH 0/6] getenv() timing fixes

2019-01-15 Thread Junio C Hamano
Jeff King writes: > On Sat, Jan 12, 2019 at 10:51:42AM -0800, Stefan Beller wrote: > >> > I wonder, and not as "you should do this" feedback on this series, just >> >> There is a getenv_safe() in environment.c, but I guess a xgetenv() that >> takes the same parameters as getenv() is better for e

Re: [PATCH 0/6] getenv() timing fixes

2019-01-15 Thread Jeff King
On Sat, Jan 12, 2019 at 10:51:42AM -0800, Stefan Beller wrote: > > I wonder, and not as "you should do this" feedback on this series, just > > There is a getenv_safe() in environment.c, but I guess a xgetenv() that > takes the same parameters as getenv() is better for ease of use. Yes, but it pu

Re: [PATCH 0/6] getenv() timing fixes

2019-01-15 Thread Jeff King
On Sat, Jan 12, 2019 at 12:31:21PM +0100, Ævar Arnfjörð Bjarmason wrote: > > So anyway. Here are a handful of what seem like pretty low-hanging > > fruit. Beyond the first one, I'm not sure if they're triggerable, but > > they're easy to fix. There are 100+ grep matches that I _didn't_ audit, > >

Re: [PATCH 0/6] getenv() timing fixes

2019-01-12 Thread Stefan Beller
> I wonder, and not as "you should do this" feedback on this series, just There is a getenv_safe() in environment.c, but I guess a xgetenv() that takes the same parameters as getenv() is better for ease of use.

Re: [PATCH 0/6] getenv() timing fixes

2019-01-12 Thread Ævar Arnfjörð Bjarmason
On Fri, Jan 11 2019, Jeff King wrote: > Similar to the recent: > > https://public-inbox.org/git/20190109221007.21624-1-kgyb...@infogroep.be/ > > there are some other places where we do not follow the POSIX rule that > getenv()'s return value may be invalidated by other calls to getenv() or > s

[PATCH 0/6] getenv() timing fixes

2019-01-11 Thread Jeff King
Similar to the recent: https://public-inbox.org/git/20190109221007.21624-1-kgyb...@infogroep.be/ there are some other places where we do not follow the POSIX rule that getenv()'s return value may be invalidated by other calls to getenv() or setenv(). For the most part we haven't noticed becaus