object-file.c: return ULHR_TOO_LONG on "header too long"
Split up the return code for "header too long" from the generic negative return value unpack_loose_header() returns, and report via error() if we exceed MAX_HEADER_LEN. As a test added earlier in this series in t1006-cat-file.sh shows we'll correctly emit zlib errors from zlib.c already in this case, so we have no need to carry those return codes further down the stack. Let's instead just return ULHR_TOO_LONG saying we ran into the MAX_HEADER_LEN limit, or other negative values for "unable to unpack <OID> header". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
3b6a8db3b0
commit
5848fb11ac
5
cache.h
5
cache.h
@ -1311,16 +1311,19 @@ int git_open_cloexec(const char *name, int flags);
|
||||
*
|
||||
* - ULHR_OK on success
|
||||
* - ULHR_BAD on error
|
||||
* - ULHR_TOO_LONG if the header was too long
|
||||
*
|
||||
* 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(), ULHR_TOO_LONG will still be returned
|
||||
* from this function to indicate that the header was too long.
|
||||
*/
|
||||
enum unpack_loose_header_result {
|
||||
ULHR_OK,
|
||||
ULHR_BAD,
|
||||
ULHR_TOO_LONG,
|
||||
};
|
||||
enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
|
||||
unsigned char *map,
|
||||
|
||||
Reference in New Issue
Block a user