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

Re: [PATCH] off-by-one bugs found by valgrind

From
PRPavel Roskin <proski@gnu.org>
Date
Dec 21, 2005, 21:47 UTC
Message-ID
<1135201641.15567.7.camel@dv>
In-Reply-To
<43A9C654.2010009@zytor.com>
On Wed, 2005-12-21 at 13:17 -0800, H. Peter Anvin wrote:
> >>quote_c_style_counted() in quote.c uses a dangerous construct, when a
> >>variable is incremented once and used twice in the same expression.
> > 
> > Sorry, I do not follow you.  Isn't && a sequence point?
The patch is right, but my comment was wrong, sorry.

The actual problem detected by valgrind is that sp is dereferenced before it's checked for the upper boundary. So, if e.g. namelen is 6, the code reads name[6] into ch and then leaves the loop.

> && is a sequence point.  The code is techically fine, but it's harder 
> than necessary to read.
That alone should be a good reason to apply this patch.
-- 
Regards,
Pavel Roskin
Previous: H. Peter Anvin
Message 4 of 4 in “off-by-one bugs found by valgrind”
  1. off-by-one bugs found by valgrindPavel Roskin, Dec 21, 2005
  2. Junio C HamanoDec 21, 2005
  3. H. Peter AnvinDec 21, 2005
  4. Pavel RoskinDec 21, 2005

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.