Re: [PATCH 5/5] pack-objects: clamp negative depth to 0
- From
Derrick Stolee <stolee@gmail.com>
- Date
- May 3, 2021, 12:11 UTC
- Message-ID
- <dd080fd4-00cc-0e53-2cbd-30871c598b4d@gmail.com>
- In-Reply-To
- <YI1f8jKReuE3LXVH@coredump.intra.peff.net>
On 5/1/2021 10:04 AM, Jeff King wrote:
Show 11 quoted lines
> A negative delta depth makes no sense, and the code is not prepared to > handle it. If passed "--depth=-1" on the command line, then this line > from break_delta_chains(): > > cur->depth = (total_depth--) % (depth + 1); > > triggers a divide-by-zero. This is undefined behavior according to the C > standard, but on POSIX systems results in SIGFPE killing the process. > This is certainly one way to inform the use that the command was > invalid, but it's a bit friendlier to just treat it as "don't allow any > deltas", which we already do for --depth=0.
Makes sense to me. This whole series LGTM.
Thanks, -Stolee