git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Correctly report corrupted objects

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Jan 20, 2011, 20:12 UTC
Message-ID
<20110120201220.GD12418@atjola.homenet>

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.

Reported-by: Will Palmer <wmpalmer@gmail.com>
Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
---
 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
Next: Junio C Hamano
Message 1 of 3 in “Correctly report corrupted objects”
  1. Correctly report corrupted objectsBjörn Steinbrink, Jan 20, 2011
  2. Junio C HamanoJan 20, 2011
  3. Junio C HamanoJan 20, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.