{"thread":{"id":"454","subject":"[PATCH] fsck-cache segfaults on a tag referring to a missing object.","startedAt":"2005-05-03T08:28:11Z","lastAt":"2005-05-03T08:28:11Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"2457","messageId":"7vzmvcww6c.fsf@assigned-by-dhcp.cox.net","threadId":"454","inReplyTo":null,"subject":"[PATCH] fsck-cache segfaults on a tag referring to a missing object.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-03T08:28:11Z","receivedAt":"2005-05-03T08:28:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I do not understand the comment about ignoring tag reachability\nin check_connectivity(), but fsck_tag() fails to notice that a\nparsing of tag may have failed in the parse_object() call in\nfsck_sha1() before it is called, in which case it can get a tag\nobject with NULL in the tagged field and segfault.  Here is a\npatch to fix this.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\nP.S. Since this is probably more urgent than other fixes I've\nbeen bugging you about, I am sending this via e-mail, not as a\nGIT pull request, but I have a couple more update there, along\nwith updated HEAD.\n\n--- a/fsck-cache.c\n+++ b/fsck-cache.c\n@@ -136,6 +136,12 @@ static int fsck_tag(struct tag *tag)\n \tif (!show_tags)\n \t\treturn 0;\n \n+\tif (!tag->tagged) {\n+\t\tprintf(\"bad referenced object in tag %s\\n\",\n+\t\t       sha1_to_hex(tag->object.sha1));\n+\t\treturn 0;\n+\t}\n+\n \tprintf(\"tagged %s %s\",\n \t       tag->tagged->type,\n \t       sha1_to_hex(tag->tagged->sha1));\n\n\n----------------------------------------------------------------\n\n"}]}