Re: [PATCH v3 2/3] commit-graph: fix buffer read-overflow
- From
Jeff King <peff@peff.net>
- Date
- Dec 11, 2018, 09:50 UTC
- Message-ID
- <20181211095002.GB31588@sigill.intra.peff.net>
- In-Reply-To
- <20181210215649.GC37614@google.com>
On Mon, Dec 10, 2018 at 01:56:49PM -0800, Josh Steadmon wrote:
Show 9 quoted lines
> > "stat(1)" is not so portable, so you'll get complaints from minority > > platform users later. So is "truncate(1)". > > Ack, thanks for the catch. I have a workaround for stat in the form of > "wc -c", and for truncate with a combination of dd and /dev/zero. > However, I'm finding conflicting information about whether or not > /dev/zero exists on macOS. At the least, it sounds like it might not > work on very old versions. Would this be acceptable, or should I add a > new test function to do this?
If you're just interested in truncation (and not a bunch of zero bytes), you can dd from /dev/null.
Another way to truncate is to move the file elsewhere, and then copy only some of the bytes back (see t1450's "fsck detects truncated loose object").
-Peff