Skip to content

Commit

Permalink
git format-patch: avoid underrun when format.headers is empty or all NLs
Browse files Browse the repository at this point in the history
* builtin-log.c (add_header): Avoid a buffer underrun when
format.headers is empty or all newlines.  Reproduce with this:
git config format.headers '' && git format-patch -1

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jim Meyering authored and gitster committed Aug 20, 2008
1 parent 26e08a0 commit c8c4450
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion builtin-log.c
Expand Up @@ -461,7 +461,7 @@ static int extra_cc_alloc;
static void add_header(const char *value)
{
int len = strlen(value);
while (value[len - 1] == '\n')
while (len && value[len - 1] == '\n')
len--;
if (!strncasecmp(value, "to: ", 4)) {
ALLOC_GROW(extra_to, extra_to_nr + 1, extra_to_alloc);
Expand Down

0 comments on commit c8c4450

Please sign in to comment.