{"thread":{"id":"668","subject":"[PATCH] Fix git-fsck-cache segfault on invalid tag","startedAt":"2005-05-20T07:00:41Z","lastAt":"2005-05-20T14:36:16Z","messageCount":4,"participants":["Frank Sorenson","Petr Baudis","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"3598","messageId":"428D8B19.4070605@tuxrocks.com","threadId":"668","inReplyTo":null,"subject":"[PATCH] Fix git-fsck-cache segfault on invalid tag","fromName":"Frank Sorenson","fromEmail":"frank@tuxrocks.com","sentAt":"2005-05-20T07:00:41Z","receivedAt":"2005-05-20T07:00:41Z","isPatch":true,"sender":{"key":"frank@tuxrocks.com","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\ngit-fsck-cache will segfault if a tag contains a non-existent sha1.  This\npatch fixes fsck-cache to report the invalid tag and not die.\n\n- ---\ncommit a6a237ee3f3d2f5d76499b8f32f58057c9b4cd2d\ntree ac5d65a040c22194ddcd0706dc5f0b8bb52aef65\nparent 5cd4c7b7686d334e341b21d92449349feda3ef65\nauthor Frank Sorenson <frank@tuxrocks.com> Fri, 20 May 2005 00:52:59 -0600\ncommitter Frank Sorenson <frank@tuxrocks.com> Fri, 20 May 2005 00:52:59 -0600\n\n fsck-cache.c |    4 ++++\n 1 files changed, 4 insertions(+)\n\nIndex: fsck-cache.c\n===================================================================\n- --- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/fsck-cache.c  (mode:100644)\n+++ ac5d65a040c22194ddcd0706dc5f0b8bb52aef65/fsck-cache.c  (mode:100644)\n@@ -315,6 +315,10 @@\n \t\treturn;\n \n \tobj = lookup_object(sha1);\n+\tif (!obj) {\n+\t\tfprintf(stderr, \"invalid tag %s - %s\\n\", path, hexname);\n+\t\treturn;\n+\t}\n \tobj->used = 1;\n \tmark_reachable(obj, REACHABLE);\n }\n\nFrank\n- -- \nFrank Sorenson - KD7TZK\nSystems Manager, Computer Science Department\nBrigham Young University\nfrank@tuxrocks.com\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.2.6 (GNU/Linux)\nComment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org\n\niD8DBQFCjYsZaI0dwg4A47wRAn2PAJ9hyoev3stnaN0Qn2wWlBJEKiucQACgvT9Z\nrVazYmUFj3nXvJDYaBoSRsM=\n=KbSv\n-----END PGP SIGNATURE-----\n"},{"id":"3599","messageId":"20050520085047.GA27787@pasky.ji.cz","threadId":"668","inReplyTo":"428D8B19.4070605@tuxrocks.com","subject":"Re: [PATCH] Fix git-fsck-cache segfault on invalid tag","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-20T08:50:47Z","receivedAt":"2005-05-20T08:50:47Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, May 20, 2005 at 09:00:41AM CEST, I got a letter\nwhere Frank Sorenson <frank@tuxrocks.com> told me that...\n> git-fsck-cache will segfault if a tag contains a non-existent sha1.  This\n> patch fixes fsck-cache to report the invalid tag and not die.\n\nOh. I've fixed this too but didn't even get to commit it yet. :-)\n\n> Index: fsck-cache.c\n> ===================================================================\n> --- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/fsck-cache.c  (mode:100644)\n> +++ ac5d65a040c22194ddcd0706dc5f0b8bb52aef65/fsck-cache.c  (mode:100644)\n> @@ -315,6 +315,10 @@\n>  \t\treturn;\n>  \n>  \tobj = lookup_object(sha1);\n> +\tif (!obj) {\n> +\t\tfprintf(stderr, \"invalid tag %s - %s\\n\", path, hexname);\n> +\t\treturn;\n> +\t}\n>  \tobj->used = 1;\n>  \tmark_reachable(obj, REACHABLE);\n>  }\n\nMy error message is\n\n\terror(\"%s: invalid sha1 pointer %.40s\", path, hexname);\n\nI'd prefer that (at least use the error() call). The .40 is there since\nit has a newline on its own.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"3607","messageId":"7voeb6uhhs.fsf@assigned-by-dhcp.cox.net","threadId":"668","inReplyTo":"20050520085047.GA27787@pasky.ji.cz","subject":"Re: [PATCH] Fix git-fsck-cache segfault on invalid tag","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-20T13:58:07Z","receivedAt":"2005-05-20T13:58:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"PB\" == Petr Baudis <pasky@ucw.cz> writes:\n\n>> obj = lookup_object(sha1);\n>> +\tif (!obj) {\n>> +\t\tfprintf(stderr, \"invalid tag %s - %s\\n\", path, hexname);\n>> +\t\treturn;\n>> +\t}\n>> ...\n\nPB> My error message is\nPB> \terror(\"%s: invalid sha1 pointer %.40s\", path, hexname);\nPB> I'd prefer that (at least use the error() call).\n\nAck.\n\nI was about to say \"doesn't lookup_object() give its own error\nmessage before you say that, though?\" because I remembered a\ncomment to that effect around ll 410 that gets the heads from\nthe command line argument, and then looked at lookup_object()\nimplementation to find that it does _not_ give error message.\n\nSo if you are going to do this, would you mind giving similar\nerror message to that command line heads stuff while you are at\nit, please?\n\n"},{"id":"3609","messageId":"428DF5E0.6030106@tuxrocks.com","threadId":"668","inReplyTo":"20050520085047.GA27787@pasky.ji.cz","subject":"Re: [PATCH] Fix git-fsck-cache segfault on invalid tag","fromName":"Frank Sorenson","fromEmail":"frank@tuxrocks.com","sentAt":"2005-05-20T14:36:16Z","receivedAt":"2005-05-20T14:36:16Z","isPatch":true,"sender":{"key":"frank@tuxrocks.com","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nPetr Baudis wrote:\n> Dear diary, on Fri, May 20, 2005 at 09:00:41AM CEST, I got a letter\n> where Frank Sorenson <frank@tuxrocks.com> told me that...\n> \n>>git-fsck-cache will segfault if a tag contains a non-existent sha1.  This\n>>patch fixes fsck-cache to report the invalid tag and not die.\n> \n> \n> Oh. I've fixed this too but didn't even get to commit it yet. :-)\n\nOkay.  At least we fixed the same bug.  It was a good exercise for me to\ntrack it down anyway :)\n\n> My error message is\n> \n> \terror(\"%s: invalid sha1 pointer %.40s\", path, hexname);\n> \n> I'd prefer that (at least use the error() call). The .40 is there since\n> it has a newline on its own.\n\nGreat.  Your message looks fine.  It looks like error() should work fine\nas well.\n\nFrank\n- --\nFrank Sorenson - KD7TZK\nSystems Manager, Computer Science Department\nBrigham Young University\nfrank@tuxrocks.com\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.2.6 (GNU/Linux)\nComment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org\n\niD8DBQFCjfXgaI0dwg4A47wRAikrAKCvPmZBQK34sdnnY61/meuewu2jzQCfT7Qf\nTDSNgfp3WBJOTvWG5uhwX4s=\n=CUF2\n-----END PGP SIGNATURE-----\n"}]}