diff options
author | Jeff King <peff@peff.net> | 2023-12-07 07:11:14 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-12-08 23:24:39 (GMT) |
commit | ba176db511b3438738a4aeb98e574310e697ff5f (patch) | |
tree | 647a878be2c8d0f0d48a8f74f9f9fcfc051fecd1 /mailinfo.c | |
parent | 564d0252ca632e0264ed670534a51d18a689ef5d (diff) | |
download | git-ba176db511b3438738a4aeb98e574310e697ff5f.zip git-ba176db511b3438738a4aeb98e574310e697ff5f.tar.gz git-ba176db511b3438738a4aeb98e574310e697ff5f.tar.bz2 |
config: handle NULL value when parsing non-bools
When the config parser sees an "implicit" bool like:
[core]
someVariable
it passes NULL to the config callback. Any callback code which expects a
string must check for NULL. This usually happens via helpers like
git_config_string(), etc, but some custom code forgets to do so and will
segfault.
These are all fairly vanilla cases where the solution is just the usual
pattern of:
if (!value)
return config_error_nonbool(var);
though note that in a few cases we have to split initializers like:
int some_var = initializer();
into:
int some_var;
if (!value)
return config_error_nonbool(var);
some_var = initializer();
There are still some broken instances after this patch, which I'll
address on their own in individual patches after this one.
Reported-by: Carlos Andrés Ramírez Cataño <antaigroupltda@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mailinfo.c')
-rw-r--r-- | mailinfo.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -1253,6 +1253,8 @@ static int git_mailinfo_config(const char *var, const char *value, return 0; } if (!strcmp(var, "mailinfo.quotedcr")) { + if (!value) + return config_error_nonbool(var); if (mailinfo_parse_quoted_cr_action(value, &mi->quoted_cr) != 0) return error(_("bad action '%s' for '%s'"), value, var); return 0; |