summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-03-28 15:39:57 -0700
committerJunio C Hamano <junkio@cox.net>2007-03-28 15:39:57 -0700
commit0a98f9d13802880a68ce6564b9f47b1c3e3341c7 (patch)
tree1465fa12fd8127c4c76405f0fc3d1c44583365d4 /commit.c
parent03bcaacaadbb325f412e6dffec27fea6acb9321e (diff)
parent9529a2524a29c15107905f2f8f0b310a40880dc7 (diff)
downloadgit-0a98f9d13802880a68ce6564b9f47b1c3e3341c7.tar.gz
Merge branch 'maint' to synchronize with 1.5.0.6
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/commit.c b/commit.c
index a4f2e74c0b..754d1b8a0b 100644
--- a/commit.c
+++ b/commit.c
@@ -654,6 +654,7 @@ static char *get_header(const struct commit *commit, const char *key)
static char *replace_encoding_header(char *buf, const char *encoding)
{
char *encoding_header = strstr(buf, "\nencoding ");
+ char *header_end = strstr(buf, "\n\n");
char *end_of_encoding_header;
int encoding_header_pos;
int encoding_header_len;
@@ -661,8 +662,10 @@ static char *replace_encoding_header(char *buf, const char *encoding)
int need_len;
int buflen = strlen(buf) + 1;
- if (!encoding_header)
- return buf; /* should not happen but be defensive */
+ if (!header_end)
+ header_end = buf + buflen;
+ if (!encoding_header || encoding_header >= header_end)
+ return buf;
encoding_header++;
end_of_encoding_header = strchr(encoding_header, '\n');
if (!end_of_encoding_header)