Re: [PATCH 2/2] nedmalloc: work around overzealous GCC 6 warning
- From
Jeff King <peff@peff.net>
- Date
- Aug 5, 2016, 07:42 UTC
- Message-ID
- <20160805074219.3vvgzaqnn6kvsh3s@sigill.intra.peff.net>
- In-Reply-To
- <xmqq7fbvzqan.fsf@gitster.mtv.corp.google.com>
On Thu, Aug 04, 2016 at 11:24:32PM -0700, Junio C Hamano wrote:
> I do not know if we want to worry about st_add(1, strlen(s1)) > overflow around here, though. > [...] > + size_t len = strlen(s1) + 1;
I wondered that, too, but I don't think it's possible.
To overflow the size_t with "+1", strlen() must return the maximum value that it can hold. But such a string would need one more byte than that, for its trailing NUL. So assuming you cannot have a string that exceeds size_t in the first place, I think it is impossible to overflow here.
-Peff