@matheusbsbs / matheus-bagliano / commits / e102d4353d
Fork 0

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 <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Alex Riesen committed May 4, 2007 at 23:51 UTC e102d4353d7cfd69a597cd976eabdcb74641be69
1 file changed +3 -1
commit.c
+3 -1
@@ -640,7 +640,9 @@ static char *get_header(const struct commit *commit, const char *key)
640 next = NULL;
641 } else
642 next = eol + 1;
643 - if (!strncmp(line, key, key_len) && line[key_len] == ' ') {
643 + if (eol - line > key_len &&
644 + !strncmp(line, key, key_len) &&
645 + line[key_len] == ' ') {
646 int len = eol - line - key_len;
647 char *ret = xmalloc(len);
648 memcpy(ret, line + key_len + 1, len - 1);