[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: vasnprintf's "%n in writable segment" chokes with _FORTIFY_SOURCE ==
Re: vasnprintf's "%n in writable segment" chokes with _FORTIFY_SOURCE == 2
Thu, 18 Oct 2007 14:02:11 +0200
Bruno Haible <address@hidden> wrote:
> Jim Meyering wrote:
>> When I build a coreutils snapshot with -D_FORTIFY_SOURCE=2 on a
>> relatively recent fedora-based system, seq always aborts like this:
>> $ ./seq 1
>> *** %n in writable segment detected ***
>> 1zsh: abort ./seq 1
>> [Exit 134 (ABRT)]
>> That is due to the fact that vasnprintf writes %n into a format
>> string that is subsequently used by snprintf.
> Use of %n is valid in ISO C99 and in POSIX.
As you know I don't dispute its validity.
However, vasnprintf.c should resort to incurring the
expense of that portability kludge only when necessary.
How about if it does that only when a configure-time test
has detected that snprintf's return value is not conforming?
Then, vasnprintf.c will be more efficient, and won't use the offending %n,
on the vast majority of systems that have an snprintf implementation
with a conforming return value.