threads / patch / 668

patchFix git-fsck-cache segfault on invalid tag

Subject: [PATCH] Fix git-fsck-cache segfault on invalid tag

## tl;dr

4 messages between May 20, 2005 and May 20, 2005. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Frank Sorenson· May 20, 2005, 07:00 UTC · lore
-----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 <frank@tuxrocks.com> Fri, 20 May 2005 00:52:59 -0600
committer Frank Sorenson <frank@tuxrocks.com> Fri, 20 May 2005 00:52:59 -0600
 fsck-cache.c |    4 ++++
 1 files changed, 4 insertions(+)
Show changes to diff +4 −2
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
frank@tuxrocks.com
-----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-----
Petr Baudis· May 20, 2005, 08:50 UTC · re: Frank Sorenson · lore

Re: [PATCH] Fix git-fsck-cache segfault on invalid tag

Dear diary, on Fri, May 20, 2005 at 09:00:41AM CEST, I got a letter where Frank Sorenson <frank@tuxrocks.com> told me that...

> 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. :-)
Show 15 quoted lines
> 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);
>  }
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.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Junio C Hamano· May 20, 2005, 13:58 UTC · re: Petr Baudis · lore

Re: [PATCH] Fix git-fsck-cache segfault on invalid tag

>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:
Show 6 quoted lines
>> obj = lookup_object(sha1);
>> +	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?

Frank Sorenson· May 20, 2005, 14:36 UTC · re: Petr Baudis · lore

Re: [PATCH] Fix git-fsck-cache segfault on invalid tag

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Petr Baudis wrote:
Show 8 quoted lines
> Dear diary, on Fri, May 20, 2005 at 09:00:41AM CEST, I got a letter
> where Frank Sorenson <frank@tuxrocks.com> told me that...
> 
>>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 :)

Show 6 quoted 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
frank@tuxrocks.com
-----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-----

← back to recent threads