From: Junio C Hamano Date: Fri, 10 Apr 2020 22:04:31 GMT Subject: Re: [PATCH 6/6] config: reject parsing of files over INT_MAX Message-ID: In-Reply-To: <20200410195007.GF1363756@coredump.intra.peff.net> Jeff King writes: > 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.