[PATCH 08/21] Switch from verify_tag() to parse_and_verify_tag_buffer() for verifying tag objects in git-mktag
From: Johan Herland <hidden>
Date: 2016-06-15 22:43:14
Subsystem:
the rest · Maintainer:
Linus Torvalds
This involves exposing parse_and_verify_tag_buffer() in the tag API (tag.h). Also synchronize selftest with change in error message. Signed-off-by: Johan Herland <redacted> --- mktag.c | 5 ++--- t/t3800-mktag.sh | 2 +- tag.c | 2 +- tag.h | 2 ++ 4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/mktag.c b/mktag.c
index 2e70504..5780f33 100644
--- a/mktag.c
+++ b/mktag.c@@ -125,9 +125,8 @@ int main(int argc, char **argv) } buffer[size] = 0; - /* Verify it for some basic sanity: it needs to start with - "object <sha1>\ntype\ntagger " */ - if (verify_tag(buffer, size) < 0) + /* Verify tag object data */ + if (parse_and_verify_tag_buffer(0, buffer, size, 1)) die("invalid tag signature file"); if (write_sha1_file(buffer, size, tag_type, result_sha1) < 0)
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
index b4edb4d..0e87d2a 100755
--- a/t/t3800-mktag.sh
+++ b/t/t3800-mktag.sh@@ -34,7 +34,7 @@ too short for a tag EOF cat >expect.pat <<EOF -^error: .*size wrong.*$ +^error: .*size.*$ EOF check_verify_failure 'Tag object length check'
diff --git a/tag.c b/tag.c
index 3896e45..e12b9fc 100644
--- a/tag.c
+++ b/tag.c@@ -51,7 +51,7 @@ static int verify_object(unsigned char *sha1, const char *expected_type) return ret; } -static int parse_and_verify_tag_buffer(struct tag *item, +int parse_and_verify_tag_buffer(struct tag *item, const char *data, const unsigned long size, int thorough_verify) { #ifdef NO_C99_FORMAT
diff --git a/tag.h b/tag.h
index 7a0cb00..f341b7f 100644
--- a/tag.h
+++ b/tag.h@@ -13,6 +13,8 @@ struct tag { }; extern struct tag *lookup_tag(const unsigned char *sha1); +extern int parse_and_verify_tag_buffer(struct tag *item, + const char *data, const unsigned long size, int thorough_verify); extern int parse_tag_buffer(struct tag *item, void *data, unsigned long size); extern int parse_tag(struct tag *item); extern struct object *deref_tag(struct object *, const char *, int);
--
1.5.2