Skip to content

Commit

Permalink
Small correction in reading of commit headers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alex Riesen authored and Junio C Hamano committed May 6, 2007
1 parent cf593cc commit e102d43
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e102d43

Please sign in to comment.