Re: [PATCH] config: fix several access(NULL) calls
From: Matthieu Moy <hidden>
Date: 2016-06-15 22:54:15
Thomas Rast [off-list ref] writes:
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/