Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Correctly report corrupted objects

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:26

Björn Steinbrink [off-list ref] writes:
The errno check added in commit 3ba7a06 "A loose object is not corrupt
if it cannot be read due to EMFILE" only checked for whether errno is
not ENOENT and thus incorrectly treated "no error" as an error
condition.

Because of that, it never reached the code path that would report that
the object is corrupted and instead caused funny errors like:

  fatal: failed to read object 333c4768ce595793fdab1ef3a036413e2a883853: Success

So we have to extend the check to cover the case in which the object
file was successfully read, but its contents are corrupted.
Hmm, what is the exact code path that read_object() callchain fails to set
errno when it returns a NULL?  It is unclear from the above description.
Is there a funny object replacement involved?
quoted hunk
Reported-by: Will Palmer <redacted>
Signed-off-by: Björn Steinbrink <redacted>
---
 sha1_file.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 1cafdfa..d86a8db 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2141,7 +2141,7 @@ void *read_sha1_file_repl(const unsigned char *sha1,
 		return data;
 	}
 
-	if (errno != ENOENT)
+	if (errno && errno != ENOENT)
 		die_errno("failed to read object %s", sha1_to_hex(sha1));
 
 	/* die if we replaced an object with one that does not exist */
-- 
1.7.4.rc2.18.gb20e9
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help