Skip to content

Commit

Permalink
Don't ever return corrupt objects from "parse_object()"
Browse files Browse the repository at this point in the history
Looking at the SHA1 validation code due to the corruption that Alexander
Litvinov is seeing under Cygwin, I notice that one of the most central
places where we read objects, we actually do end up verifying the SHA1 of
the result, but then we happily parse it anyway.

And using "printf" to write the error message means that it not only can
get lost, but will actually mess up stdout, and cause other strange and
hard-to-debug failures downstream.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Mar 21, 2007
1 parent 9096c66 commit acdeec6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ struct object *parse_object(const unsigned char *sha1)

if (buffer) {
struct object *obj;
if (check_sha1_signature(sha1, buffer, size, typename(type)) < 0)
printf("sha1 mismatch %s\n", sha1_to_hex(sha1));
if (check_sha1_signature(sha1, buffer, size, typename(type)) < 0) {
error("sha1 mismatch %s\n", sha1_to_hex(sha1));
return NULL;
}

obj = parse_object_buffer(sha1, type, size, buffer, &eaten);
if (!eaten)
Expand Down

0 comments on commit acdeec6

Please sign in to comment.