From: Alex Riesen Date: Fri, 4 May 2007 21:51:32 +0000 (+0200) Subject: Small correction in reading of commit headers X-Git-Tag: v1.5.2-rc2~1^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e102d4353d7cfd69a597cd976eabdcb74641be69;p=git.git Small correction in reading of commit headers Check if a line of the header has enough characters to possibly contain the requested prefix. Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- diff --git a/commit.c b/commit.c index eb911f44d..7d78e786e 100644 --- a/commit.c +++ b/commit.c @@ -640,7 +640,9 @@ static char *get_header(const struct commit *commit, const char *key) next = NULL; } else next = eol + 1; - if (!strncmp(line, key, key_len) && line[key_len] == ' ') { + if (eol - line > key_len && + !strncmp(line, key, key_len) && + line[key_len] == ' ') { int len = eol - line - key_len; char *ret = xmalloc(len); memcpy(ret, line + key_len + 1, len - 1);