* [PATCH] Correctly report corrupted objects
@ 2011-01-20 20:12 Björn Steinbrink
2011-01-20 21:05 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Björn Steinbrink @ 2011-01-20 20:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Will Palmer
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Correctly report corrupted objects
2011-01-20 20:12 [PATCH] Correctly report corrupted objects Björn Steinbrink
@ 2011-01-20 21:05 ` Junio C Hamano
2011-01-20 21:17 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2011-01-20 21:05 UTC (permalink / raw)
To: Björn Steinbrink; +Cc: git, Will Palmer
Björn Steinbrink <B.Steinbrink@gmx.de> 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?
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Correctly report corrupted objects
2011-01-20 21:05 ` Junio C Hamano
@ 2011-01-20 21:17 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2011-01-20 21:17 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Björn Steinbrink, git, Will Palmer
Junio C Hamano <gitster@pobox.com> writes:
> Björn Steinbrink <B.Steinbrink@gmx.de> 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.
Ah, nevermind. I wasn't thinking. If for example unpack_sha1_header()
says the type bits are garbled, it will return -1 without having any
system calls failed up to that point (because the file itself was mmapped
and read correctly) and the calling unpack_sha1_file() will return NULL.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-20 21:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-20 20:12 [PATCH] Correctly report corrupted objects Björn Steinbrink
2011-01-20 21:05 ` Junio C Hamano
2011-01-20 21:17 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).