[PATCH] fsck: do not crash on tag objects which do not contain an empty line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The first empty line in a tag object separates the header from the
message. If the tag object has no empty line, do not crash, but
complain loudly instead.

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---

	I have no idea how this tag crept into one of my repos, but it is 
	no good to crash for git-fsck.

 builtin-fsck.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/builtin-fsck.c b/builtin-fsck.c
index 7a92e47..607136a 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -545,9 +545,14 @@ static void fsck_verify_ref_to_tag_object(const char *refname, struct object *ob
 {
 	/* Verify that refname matches the name stored in obj's "tag" header */
 	struct tag *tagobj = (struct tag *) parse_object(obj->sha1);
-	size_t tagname_len = strlen(tagobj->tag);
+	size_t tagname_len;
 	size_t refname_len = strlen(refname);
 
+	if (!tagobj->tag) {
+		error("tag %s does not contain any tag?", refname);
+		return;
+	}
+	tagname_len = strlen(tagobj->tag);
 	if (!tagname_len) return; /* No tag name stored in tagobj. Nothing to do. */
 
 	if (tagname_len < refname_len &&
-- 
1.5.2.1.2683.gab86-dirty

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux