Re: [PATCH 1/5] pack-objects: pass length to check_pack_crc() without truncation

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

 



Nguyễn Thái Ngọc Duy  <pclouds@xxxxxxxxx> writes:

> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> index 8f5e358..df6ecd5 100644
> --- a/builtin/pack-objects.c
> +++ b/builtin/pack-objects.c
> @@ -349,7 +349,7 @@ static unsigned long write_reuse_object(struct sha1file *f, struct object_entry
>  	struct revindex_entry *revidx;
>  	off_t offset;
>  	enum object_type type = entry->type;
> -	unsigned long datalen;
> +	off_t datalen;
>  	unsigned char header[10], dheader[10];
>  	unsigned hdrlen;
>  
> diff --git a/sha1_file.c b/sha1_file.c
> index d5e1121..cb571ac 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -2281,7 +2281,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
>  
>  		if (do_check_packed_object_crc && p->index_version > 1) {
>  			struct revindex_entry *revidx = find_pack_revindex(p, obj_offset);
> -			unsigned long len = revidx[1].offset - obj_offset;
> +			off_t len = revidx[1].offset - obj_offset;
>  			if (check_pack_crc(p, &w_curs, obj_offset, len, revidx->nr)) 

It is sad that check_pack_crc() already knew to take off_t here and
we (unknowingly) had a deliberate truncation by using ulong.
Looks obvioiusly correct.

Thanks.

{
>  				const unsigned char *sha1 =
>  					nth_packed_object_sha1(p, revidx->nr);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]