Re: [PATCH v3 12/17] object-file.c: return -2 on "header too long" in unpack_loose_header()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> diff --git a/object-store.h b/object-store.h
> index 740edcac30..9accb614fc 100644
> --- a/object-store.h
> +++ b/object-store.h
> @@ -481,13 +481,15 @@ int for_each_packed_object(each_packed_object_fn, void *,
>   * unpack_loose_header() initializes the data stream needed to unpack
>   * a loose object header.
>   *
> - * Returns 0 on success. Returns negative values on error.
> + * Returns 0 on success. Returns negative values on error. If the
> + * header exceeds MAX_HEADER_LEN -2 will be returned.
>   *
>   * It will only parse up to MAX_HEADER_LEN bytes unless an optional
>   * "hdrbuf" argument is non-NULL. This is intended for use with
>   * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
>   * reporting. The full header will be extracted to "hdrbuf" for use
> - * with parse_loose_header().
> + * with parse_loose_header(), -2 will still be returned from this
> + * function to indicate that the header was too long.
>   */
>  int unpack_loose_header(git_zstream *stream, unsigned char *map,
>  			unsigned long mapsize, void *buffer,

Can the return type be an enum in this case?

> diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
> index d3d3fd733a..f12b06150e 100755
> --- a/t/t1006-cat-file.sh
> +++ b/t/t1006-cat-file.sh
> @@ -440,7 +440,7 @@ bogus_sha1=$(echo_without_newline "$bogus_content" | git hash-object -t $bogus_t
>  
>  test_expect_success 'die on broken object with large type under -t and -s without --allow-unknown-type' '
>  	cat >err.expect <<-EOF &&
> -	error: unable to unpack $bogus_sha1 header
> +	error: header for $bogus_sha1 too long, exceeds 32 bytes
>  	fatal: git cat-file: could not get object info
>  	EOF

Ah, the error message is much more informative - thanks.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux