Fix git-fsck-cache segfault on invalid tag
PATCH 1/1 Fix git-fsck-cache segfault on invalid tag
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
git-fsck-cache will segfault if a tag contains a non-existent sha1. This patch fixes fsck-cache to report the invalid tag and not die.
- ---
commit a6a237ee3f3d2f5d76499b8f32f58057c9b4cd2d
tree ac5d65a040c22194ddcd0706dc5f0b8bb52aef65
parent 5cd4c7b7686d334e341b21d92449349feda3ef65
author Frank Sorenson <[email protected]> Fri, 20 May 2005 00:52:59 -0600 committer Frank Sorenson <[email protected]> Fri, 20 May 2005 00:52:59 -0600
fsck-cache.c | 4 ++++ 1 files changed, 4 insertions(+)
Index: fsck-cache.c
===================================================================
- --- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/fsck-cache.c (mode:100644) +++ ac5d65a040c22194ddcd0706dc5f0b8bb52aef65/fsck-cache.c (mode:100644) @@ -315,6 +315,10 @@
return;
obj = lookup_object(sha1);
+ if (!obj) {
+ fprintf(stderr, "invalid tag %s - %s\n", path, hexname);
+ return;
+ }
obj->used = 1;
mark_reachable(obj, REACHABLE);
}
Frank
- --
Frank Sorenson - KD7TZK
Systems Manager, Computer Science Department
Brigham Young University
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCjYsZaI0dwg4A47wRAn2PAJ9hyoev3stnaN0Qn2wWlBJEKiucQACgvT9Z rVazYmUFj3nXvJDYaBoSRsM=
=KbSv
-----END PGP SIGNATURE-----
Dear diary, on Fri, May 20, 2005 at 09:00:41AM CEST, I got a letter where Frank Sorenson <[email protected]> told me that...
Quoted 2 lines
git-fsck-cache will segfault if a tag contains a non-existent sha1. This patch fixes fsck-cache to report the invalid tag and not die.
Oh. I've fixed this too but didn't even get to commit it yet. :-)
Quoted 5 lines
Index:
fsck-cache.c
===================================================================
fsck-cache.c (mode:100644) line 324
Quoted 10 lines
fsck-cache.c (mode:100644) +4
-0@@ -315,6 +315,10 @@ return; obj = lookup_object(sha1); + if (!obj) { + fprintf(stderr, "invalid tag %s - %s\n", path, hexname); + return; + } obj->used = 1; mark_reachable(obj, REACHABLE); }
My error message is
error("%s: invalid sha1 pointer %.40s", path, hexname);I'd prefer that (at least use the error() call). The .40 is there since it has a newline on its own.
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 8 lines · Petr Baudis
Dear diary, on Fri, May 20, 2005 at 09:00:41AM CEST, I got a letter where Frank Sorenson <[email protected]> told me that...
Quoted 2 lines
git-fsck-cache will segfault if a tag contains a non-existent sha1. This patch fixes fsck-cache to report the invalid tag and not die.
Oh. I've fixed this too but didn't even get to commit it yet. :-)
Okay. At least we fixed the same bug. It was a good exercise for me to track it down anyway :)
Quoted 6 lines
My error message is
error("%s: invalid sha1 pointer %.40s", path, hexname);I'd prefer that (at least use the
error()call). The .40 is there since it has a newline on its own.
Great. Your message looks fine. It looks like error() should work fine as well.
Frank
- --
Frank Sorenson - KD7TZK
Systems Manager, Computer Science Department
Brigham Young University
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCjfXgaI0dwg4A47wRAikrAKCvPmZBQK34sdnnY61/meuewu2jzQCfT7Qf TDSNgfp3WBJOTvWG5uhwX4s=
=CUF2
-----END PGP SIGNATURE-----
Quoted 8 lines
Review
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"PB" == Petr Baudis <[email protected]> writes:
obj =
lookup_object(sha1);(quoted diff) +4
-0+ if (!obj) { + fprintf(stderr, "invalid tag %s - %s\n", path, hexname); + return; + }
PB> My error message is
PB> error("%s: invalid sha1 pointer %.40s", path, hexname);
PB> I'd prefer that (at least use the error() call).
Ack.
I was about to say "doesn't lookup_object() give its own error message before you say that, though?" because I remembered a comment to that effect around ll 410 that gets the heads from the command line argument, and then looked at lookup_object() implementation to find that it does _not_ give error message.
So if you are going to do this, would you mind giving similar error message to that command line heads stuff while you are at it, please?