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

Re: Git string manipulation functions wrong?

From
Karl Hasselström <kha@treskal.com>
Date
May 21, 2007, 14:59 UTC
Message-ID
<20070521145925.GA6474@diana.vm.bytemark.co.uk>
In-Reply-To
<20070521143616.GG4489@pasky.or.cz>
On 2007-05-21 16:36:16 +0200, Petr Baudis wrote:
Show 5 quoted lines
> It's the opposite for me - we don't properly set the NUL byte for
> smoe of our strncpy() calls, but I don't really see his problem with
> snprintf(), we seem to handle its return value correctly everywhere
> (except diff.c, but there the buffer sizes should be designed in
> such a way that an overflow should be impossible).

I think this kind of detailed case-by-case analysis defeats Timo's point, though: that the C library functions make it too easy to write bugs. If it's necessary to do non-trivial bounds checking etc. at every call site, it doesn't really matter if we currently do get them all right; at some point, we _are_ going to miss one. Instead of using our collective C-fu to get difficult calls right, we should be using it to construct string routines that have low enough overhead that it's lost in the noise, and are dead simple to use (and, of course, that can be cleanly bypassed in the 1% of cases where it's necessary).

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Previous: Petr BaudisNext: Kyle Moffett
Message 3 of 4 in “Git string manipulation functions wrong?”
  1. Erik MouwMay 21, 2007
  2. Petr BaudisMay 21, 2007
  3. Karl HasselströmMay 21, 2007
  4. Kyle MoffettMay 23, 2007

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.