Skip to content

Commit 24942ef

Browse files
peffgitster
authored andcommitted
trace2: handle NULL values in tr2_sysenv config callback
If you have config with an implicit bool like: [trace2] envvars we'll segfault, as we unconditionally try to xstrdup() the value. We should instead detect and complain, as a boolean value has no meaning here. The same is true for every variable in tr2_sysenv_settings (and this patch covers them all, as we check them in a loop). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a627126 commit 24942ef

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

trace2/tr2_sysenv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ static int tr2_sysenv_cb(const char *key, const char *value,
6868

6969
for (k = 0; k < ARRAY_SIZE(tr2_sysenv_settings); k++) {
7070
if (!strcmp(key, tr2_sysenv_settings[k].git_config_name)) {
71+
if (!value)
72+
return config_error_nonbool(key);
7173
free(tr2_sysenv_settings[k].value);
7274
tr2_sysenv_settings[k].value = xstrdup(value);
7375
return 0;

0 commit comments

Comments
 (0)