Re: [PATCH] config: fix several access(NULL) calls
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jul 13, 2012, 14:23 UTC
- Message-ID
- <vpq1ukf68ow.fsf@bauges.imag.fr>
- In-Reply-To
- <87hatboiwr.fsf@thomas.inf.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
Show 8 quoted lines
> Umm, are you sure? I may be somewhat confused about this, but the tests > I used to trigger the access(NULL) were IIRC > > unset HOME > git config --get foo.bar > git config --global --get foo.bar > > none of which is writing....
I was inaccurate, but that doesn't change the conclusion: the question is not reading Vs writting, but use of --global Vs no use of it (and most of the time, --global is used for writing, hence my confusion).
Both the patch that introduce the NULL bug and the one that fix it touch two files: $git/config.c, and $git/builtin/config.c.
My changes to $git/config.c, are straightforward because they touch positive tests for file existance. The controversial one is $git/builtin/config.c, which is inside a "if (use_global_config)".
This piece of code was already dying on unset $HOME, and in my proposal it still is.
The old code was:
if (use_global_config) {
char *home = getenv("HOME");
if (home) {
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
given_config_file = user_config;
} else {
die("$HOME not set");
}
}-- Matthieu Moy http://www-verimag.imag.fr/~moy/