{"thread":{"id":"15084","subject":"[PATCH] git format-patch: avoid underrun when format.headers is empty or all NLs","startedAt":"2008-08-19T13:23:25Z","lastAt":"2008-08-19T13:23:25Z","messageCount":1,"participants":["Jim Meyering"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"87687","messageId":"87iqtxyw8i.fsf@rho.meyering.net","threadId":"15084","inReplyTo":null,"subject":"[PATCH] git format-patch: avoid underrun when format.headers is empty or all NLs","fromName":"Jim Meyering","fromEmail":"jim@meyering.net","sentAt":"2008-08-19T13:23:25Z","receivedAt":"2008-08-19T13:23:25Z","isPatch":true,"sender":{"key":"jim@meyering.net","avatar":"https://avatars.githubusercontent.com/u/710630?v=4"},"body":"\n* builtin-log.c (add_header): Avoid a buffer underrun when\nformat.headers is empty or all newlines.  Reproduce with this:\ngit config format.headers '' && git format-patch -1\n---\nI spotted this via inspection.\n\n builtin-log.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex f4975cf..911fd65 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -461,7 +461,7 @@ static int extra_cc_alloc;\n static void add_header(const char *value)\n {\n \tint len = strlen(value);\n-\twhile (value[len - 1] == '\\n')\n+\twhile (len && value[len - 1] == '\\n')\n \t\tlen--;\n \tif (!strncasecmp(value, \"to: \", 4)) {\n \t\tALLOC_GROW(extra_to, extra_to_nr + 1, extra_to_alloc);\n--\n1.6.0.4.g750768\n"}]}