Re: [PATCH 0/2] friendlier handling of overflows in archive-tar
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 21, 2016, 18:43 UTC
- Message-ID
- <xmqqtwgmpell.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20160621161604.GA17638@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 35 quoted lines
> Junio, this is the jk/big-and-old-archive-tar topic.
>
> The interdiff is:
> ...
> diff --git a/archive-tar.c b/archive-tar.c
> index c7b85fd..ed562d4 100644
> --- a/archive-tar.c
> +++ b/archive-tar.c
> @@ -179,7 +179,7 @@ static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)
>
> static inline unsigned long ustar_size(uintmax_t size)
> {
> - if (size < 077777777777UL)
> + if (size <= 077777777777UL)
> return size;
> else
> return 0;
> @@ -187,7 +187,7 @@ static inline unsigned long ustar_size(uintmax_t size)
>
> static inline unsigned long ustar_mtime(time_t mtime)
> {
> - if (mtime < 077777777777UL)
> + if (mtime <= 077777777777UL)
> return mtime;
> else
> return 0;
> @@ -299,7 +299,7 @@ static int write_tar_entry(struct archiver_args *args,
> memcpy(header.linkname, buffer, size);
> }
>
> - if (ustar_size(size) != size)
> + if (S_ISREG(mode) && ustar_size(size) != size)
> strbuf_append_ext_header_uint(&ext_header, "size", size);
> if (ustar_mtime(args->time) != args->time)
> strbuf_append_ext_header_uint(&ext_header, "mtime", args->time);Thanks.
By the way, I realized the naming mistake and the topic branch is now named s/old/future/. Size being big is one condition that needs this fix, so is timestamp being from far future, not "old".