summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-20 11:01:37 -0700
committerJunio C Hamano <gitster@pobox.com>2011-10-20 11:04:40 -0700
commitc571efcc7bab061b994f0b69f2a2132b481a092c (patch)
treea58f2f9d10be3c1032d0739c5c363a7860f56ea3
parent87009edcbd0b4987ccb7ba050a1efe368a315753 (diff)
downloadgit-c571efcc7bab061b994f0b69f2a2132b481a092c.tar.gz
parse_commit_buffer(): notice NUL in the commit buffer
It is unusual to have NUL byte appear anywhere in the commit object. Leave a note in the commit object if we notice such a case while parsing the buffer for structural information, so that codepaths that want to be extra careful can inspect it further. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--commit.c1
-rw-r--r--commit.h4
2 files changed, 5 insertions, 0 deletions
diff --git a/commit.c b/commit.c
index 73b7e00292..0f58471602 100644
--- a/commit.c
+++ b/commit.c
@@ -258,6 +258,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
if (item->object.parsed)
return 0;
item->object.parsed = 1;
+ item->flags = memchr(buffer, '\0', size) ? COMMIT_HAS_NUL : 0;
tail += size;
if (tail <= bufptr + 46 || memcmp(bufptr, "tree ", 5) || bufptr[45] != '\n')
return error("bogus commit object %s", sha1_to_hex(item->object.sha1));
diff --git a/commit.h b/commit.h
index 009b113e5b..dd5e27802c 100644
--- a/commit.h
+++ b/commit.h
@@ -15,6 +15,10 @@ struct commit {
struct object object;
void *util;
unsigned int indegree;
+
+ unsigned flags;
+#define COMMIT_HAS_NUL 01
+
unsigned long date;
struct commit_list *parents;
struct tree *tree;