aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2007-05-04 23:51:32 +0200
committerJunio C Hamano <junkio@cox.net>2007-05-05 23:46:18 -0700
commite102d4353d7cfd69a597cd976eabdcb74641be69 (patch)
tree83c1756b9a4436c99ff85286a008852ef0912f51
parentcf593cc41828c6fc0a2cec50ddac0713ea8a07ec (diff)
downloadgit-e102d4353d7cfd69a597cd976eabdcb74641be69.tar.gz
git-e102d4353d7cfd69a597cd976eabdcb74641be69.tar.xz
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>
-rw-r--r--commit.c4
1 files changed, 3 insertions, 1 deletions
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);