git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Junio C HamanoNext: Johannes Schindelin
Message 12 of 17 in “Patches to let Git build with GCC 6 and DEVELOPER=SureWhyNot”
  1. 0/2 Patches to let Git build with GCC 6 and DEVELOPER=SureWhyNotJohannes Schindelin, Aug 4, 2016
  2. 1/2 nedmalloc: fix misleading indentationJohannes Schindelin, Aug 4, 2016
  3. 2/2 nedmalloc: work around overzealous GCC 6 warningJohannes Schindelin, Aug 4, 2016
  4. Junio C HamanoAug 4, 2016
  5. Johannes SchindelinAug 5, 2016
  6. René ScharfeAug 4, 2016
  7. Junio C HamanoAug 4, 2016
  8. Junio C HamanoAug 4, 2016
  9. Johannes SixtAug 5, 2016
  10. Johannes SixtAug 5, 2016
  11. Junio C HamanoAug 5, 2016
  12. Jeff KingAug 5, 2016
  13. Johannes SchindelinAug 5, 2016
  14. Junio C HamanoAug 5, 2016
  15. Johannes SchindelinAug 6, 2016
  16. Junio C HamanoAug 5, 2016
  17. René ScharfeAug 5, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.