summaryrefslogtreecommitdiff
path: root/commit.c
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 /commit.c
parentcf593cc41828c6fc0a2cec50ddac0713ea8a07ec (diff)
downloadgit-e102d4353d7cfd69a597cd976eabdcb74641be69.tar.gz
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>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/commit.c b/commit.c
index eb911f44d7..7d78e786e9 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);