bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: %.1s format with vasnprintf reads more than one byte from argument


From: Ben Pfaff
Subject: Re: %.1s format with vasnprintf reads more than one byte from argument
Date: Mon, 23 Feb 2009 20:18:32 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Bruno Haible <address@hidden> writes:

>> The culprit is pretty clearly this code in lib/vasnprintf.c:
>> 
>>                  case 's':
>> [...]
>>                      tmp_length = strlen (a.arg[dp->arg_index].a.a_string);
>>                    break;
>
> How did you find this? I thought that valgrind only runs on modern
> platforms, which all have snprintf.

I don't know.  Somehow the GNU PSPP current Git tree selected
this case when I configured it on a modern GNU/Linux system, and
so it came up when I was running a test under valgrind.  But it
only did it after I had done some manual editing of Makefiles,
etc. produced by configure, and much source hacking.  And then I
was unable to reproduce it with "gnulib-tool --create-testdir".
So to make sure that it could really happen in a simple test
case, I forced !USE_SNPRINTF by editing vasnprintf.c manually.

The one interesting thing I did to the Makefiles was to set
CFLAGS (not AM_CFLAGS) manually, to a value that used -O0 instead
of -O2 (so that debugging with GDB would be easier).  I don't
know how this could cause such a problem, though.

Thank you for the fix!

One oddity of the fixed version (at least as it appeared in my
email client) is that the comments include a number of usages of
the ligature for "fi", in the word "specified", instead of
separate letters "f" and "i".  I guess that you must have cut and
pasted from an ISO document that included those ligatures.
-- 
"Because computer source code is an expressive means for the exchange
 of information and ideas about computer programming, we hold that it
 is protected by the First Amendment."
--Hon. Boyce F. Martin, Jr., for the 6th Circuit Court, Junger vs. Daley




reply via email to

[Prev in Thread] Current Thread [Next in Thread]