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

Re: [PATCH] ls-files: use correct format string

From
Jeff King <peff@peff.net>
Date
Apr 11, 2019, 04:18 UTC
Message-ID
<20190411041823.GA17699@sigill.intra.peff.net>
In-Reply-To
<20190407184751.28027-1-t.gummerer@gmail.com>
On Sun, Apr 07, 2019 at 07:47:51PM +0100, Thomas Gummerer wrote:
Show 9 quoted lines
> struct stat_data and struct cache_time both use unsigned ints for all
> their members.  However the format string for 'git ls-files --debug'
> currently uses %d for formatting these numbers.  This means that we
> potentially print these values incorrectly if they are greater than
> INT_MAX.
> 
> This has been the case since the --debug option was introduced in 'git
> ls-files' in 8497421715 ("ls-files: learn a debugging dump format",
> 2010-07-31).

I didn't see any comment on this, but it seems like it must be obviously correct, since as you note we do define those fields as unsigned. I'm really surprised that -Wformat doesn't catch this, though. I wonder why.

-Peff
Previous: Thomas GummererNext: Thomas Gummerer
Message 2 of 4 in “ls-files: use correct format string”
  1. ls-files: use correct format stringThomas Gummerer, Apr 7, 2019
  2. Jeff KingApr 11, 2019
  3. Thomas GummererApr 11, 2019
  4. Jeff KingApr 11, 2019

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.