Re: git hang with corrupted .pack
- From
Nicolas Pitre <nico@fluxnic.net>
- Date
- Oct 20, 2009, 19:46 UTC
- Message-ID
- <alpine.LFD.2.00.0910201538180.21460@xanadu.home>
- In-Reply-To
- <7vpr8hn9ly.fsf@alter.siamese.dyndns.org>
On Tue, 20 Oct 2009, Junio C Hamano wrote:
Show 18 quoted lines
> Perhaps it would be as simple as this?
>
> We deliberately give one byte more than what we expect to see and error
> out when we do get that extra byte filled.
>
> sha1_file.c | 17 +++++++++--------
> 1 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/sha1_file.c b/sha1_file.c
> index 4cc8939..8c9f392 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -1344,7 +1344,7 @@ unsigned long get_size_from_delta(struct packed_git *p,
> off_t curpos)
> {
> const unsigned char *data;
> - unsigned char delta_head[20], *in;
> + unsigned char delta_head[21], *in;I didn't spend the time needed to think about this issue and your proposed fix yet. However I think that using sizeof(delta_head)-1 makes the code a bit confusing. At this point i'd use:
int size = sizeof(delta_head) - 1;
and use that variable instead just like it is done in unpack_compressed_entry() to have the same code pattern.
Nicolas