git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Thomas Braun <thomas.braun@virtuell-zuhause.de>
Cc: Florian Adamus <florian-adamus@gmx.de>, git@vger.kernel.org
Subject: Re: Commiting files larger than 4 GB on Windows
Date: Wed, 15 Mar 2017 12:13:08 -0400	[thread overview]
Message-ID: <20170315161308.sbyoxzst7ffcu6qs@sigill.intra.peff.net> (raw)
In-Reply-To: <20170315155952.x2tpiudi6rbqidvi@sigill.intra.peff.net>

On Wed, Mar 15, 2017 at 11:59:52AM -0400, Jeff King wrote:

> I agree that detecting the situation in the meantime is a good idea.
> The patch above probably handles the bulk-checkin code path, I'd guess.
> It might be nice to have similar checks in other places, too:
> 
>   - when reading from an existing packfile
> 
>     Looks like we may already have such a check in
>     unpack_object_header_buffer().
> 
>   - when taking in new objects via index-pack or unpack-objects (to
>     catch a fetch of a too-big object)
> 
>     I think index-pack.c:unpack_raw_entry() would want a similar check
>     to what is in unpack_object_header_buffer().

Here are the results of a few quick experiments using two versions of
git, one built for 32-bit and one for 64-bit:

  $ git init
  $ dd if=/dev/zero of=foo.zero bs=1M count=4097
  $ git32 add foo.zero
  fatal: Cannot handle files this big

That comes from the xsize_t() wrapper. I guess it wouldn't trigger on
Windows, though, because it is measuring size_t, not "unsigned long" (on
my 32-bit build they are the same, of course).

  $ git64 add foo.zero
  $ git32 cat-file blob :foo.zero
  error: bad object header
  fatal: packed object df6f032f301d1ce40477eefa505f2fac1de5e243 (stored in .git/objects/pack/pack-57d422f19904e9651bec43d10b7a9cd882de48ac.pack) is corrupt

So we notice, which is good. This is the message from
unpack_object_header_buffer(). It might be worth improving the error
message to mention the integer overflow.

And here's what index-pack looks like:

  $ git32 index-pack --stdin <.git/objects/pack/*.pack
  fatal: pack has bad object at offset 12: inflate returned -5

It's good that we notice, but the error message isn't great. What
happens is that we overflow the size integer, allocate a too-small
buffer, and then zlib complains when we run out of buffer but there's
still content to inflate. We probably ought to notice the integer
overflow in the first place and complain there.

-Peff

  reply	other threads:[~2017-03-15 16:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15 13:00 Commiting files larger than 4 GB on Windows Florian Adamus
2017-03-15 13:48 ` Thomas Braun
2017-03-15 15:59   ` Jeff King
2017-03-15 16:13     ` Jeff King [this message]
2017-03-15 18:23       ` Thomas Braun
2017-03-15 21:15       ` Torsten Bögershausen
2017-03-15 21:29         ` Junio C Hamano
2017-03-17  5:29           ` Torsten Bögershausen
2017-03-18 13:03             ` Thomas Braun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170315161308.sbyoxzst7ffcu6qs@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=florian-adamus@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=thomas.braun@virtuell-zuhause.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).