[PATCH 08/21] Switch from verify_tag() to parse_and_verify_tag_buffer() for verifying tag objects in git-mktag

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

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 <johan@herland.net>
---
 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


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/21] Refactor the tag object (take 2), Johan Herland, (Fri Jun 8, 5:10 pm)
[PATCH 02/21] Return error messages when parsing fails., Johan Herland, (Fri Jun 8, 5:13 pm)
[PATCH 08/21] Switch from verify_tag() to parse_and_verify ..., Johan Herland, (Fri Jun 8, 5:15 pm)
[PATCH 09/21] Remove unneeded code from mktag.c, Johan Herland, (Fri Jun 8, 5:16 pm)
[PATCH 10/21] Free mktag's buffer before dying, Johan Herland, (Fri Jun 8, 5:16 pm)
[PATCH 17/21] Update comments on tag objects in mktag.c, Johan Herland, (Fri Jun 8, 5:20 pm)
Re: [PATCH 03/21] Refactoring to make verify_tag() and par ..., Johannes Schindelin, (Fri Jun 8, 7:54 pm)
Re: [PATCH 10/21] Free mktag's buffer before dying, Alex Riesen, (Sat Jun 9, 2:37 pm)
Re: [PATCH 09/21] Remove unneeded code from mktag.c, Alex Riesen, (Sat Jun 9, 2:39 pm)
Re: [PATCH 09/21] Remove unneeded code from mktag.c, Johan Herland, (Sat Jun 9, 2:42 pm)
Re: [PATCH 10/21] Free mktag's buffer before dying, Johan Herland, (Sat Jun 9, 2:46 pm)
Re: [PATCH 10/21] Free mktag's buffer before dying, Alex Riesen, (Sat Jun 9, 3:00 pm)
Re: [PATCH 10/21] Free mktag's buffer before dying, Johan Herland, (Sat Jun 9, 3:05 pm)
Re: [PATCH 05/21] Make parse_tag_buffer_internal() handle ..., Johannes Schindelin, (Sun Jun 10, 1:06 am)
Re: [PATCH 06/21] Refactor tag name verification loop to u ..., Johannes Schindelin, (Sun Jun 10, 1:14 am)
Re: [PATCH 07/21] Copy the remaining differences from veri ..., Johannes Schindelin, (Sun Jun 10, 1:22 am)
Re: [PATCH 10/21] Free mktag's buffer before dying, Johannes Schindelin, (Sun Jun 10, 1:38 am)
Re: [PATCH 11/21] Rewrite error messages; fix up line lengths, Johannes Schindelin, (Sun Jun 10, 1:38 am)
Re: [PATCH 12/21] Use prefixcmp() instead of memcmp() for ..., Johannes Schindelin, (Sun Jun 10, 1:41 am)
Re: [PATCH 13/21] Collect skipping of header field names a ..., Johannes Schindelin, (Sun Jun 10, 1:45 am)
Re: [PATCH 06/21] Refactor tag name verification loop to u ..., Johannes Schindelin, (Sun Jun 10, 2:01 am)