Skip to content

Commit e102d43

Browse files
raalkmlJunio C Hamano
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cf593cc commit e102d43

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

commit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,9 @@ static char *get_header(const struct commit *commit, const char *key)
640640
next = NULL;
641641
} else
642642
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] == ' ') {
644646
int len = eol - line - key_len;
645647
char *ret = xmalloc(len);
646648
memcpy(ret, line + key_len + 1, len - 1);

0 commit comments

Comments
 (0)