Re: [PATCH 6/6] config: reject parsing of files over INT_MAX
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 10, 2020, 22:04 UTC
- Message-ID
- <xmqqzhbjgfps.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200410195007.GF1363756@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> So given the fact that these are insane cases which we have no need to > support, the weird behavior from feeding the results to printf even if > the code is careful, and the possibility of uncareful code introducing > its own integer truncation issues, let's just declare INT_MAX as a limit > for parsing config files.
Makes sense.
> + if (c != EOF && ++cf->total_len > INT_MAX) {Would this work correctly if size_t is uint? Sure, as int-max would fit within it. And of course if size_t is wider than uint, there is no problem in this comparison.
Thanks.