Skip to content

Commit 1b274c9

Browse files
peffgitster
authored andcommitted
trailer: handle NULL value when parsing trailer-specific config
When parsing the "key", "command", and "cmd" trailer config, we just make a copy of the value string. If we see an implicit bool like: [trailer "foo"] key we'll segfault trying to copy a NULL pointer. We can fix this with the usual config_error_nonbool() check. I split this out from the other vanilla cases, because at first glance it looks like a better fix here would be to move the NULL check out of the switch statement. But it would change the behavior of other keys like trailer.*.ifExists, where an implicit bool is interpreted as EXISTS_DEFAULT. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34b1a0d commit 1b274c9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

trailer.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,16 +553,22 @@ static int git_trailer_config(const char *conf_key, const char *value,
553553
case TRAILER_KEY:
554554
if (conf->key)
555555
warning(_("more than one %s"), conf_key);
556+
if (!value)
557+
return config_error_nonbool(conf_key);
556558
conf->key = xstrdup(value);
557559
break;
558560
case TRAILER_COMMAND:
559561
if (conf->command)
560562
warning(_("more than one %s"), conf_key);
563+
if (!value)
564+
return config_error_nonbool(conf_key);
561565
conf->command = xstrdup(value);
562566
break;
563567
case TRAILER_CMD:
564568
if (conf->cmd)
565569
warning(_("more than one %s"), conf_key);
570+
if (!value)
571+
return config_error_nonbool(conf_key);
566572
conf->cmd = xstrdup(value);
567573
break;
568574
case TRAILER_WHERE:

0 commit comments

Comments
 (0)