Hi list,
the problem is reproduced when building elfutils with
-D_FORTIFY_SOURCE=2 and then:
# ./src/nm -f bsd ./src/nm
*** invalid %N$ use detected ***
Aborted
The problem is in the following suite of format strings in nm.c:
[radix_hex] = "%8$s%2$0*1$" PRIx64 "%10$s %9$s%3$c%4$s %5$s",
[radix_decimal] = "%8$s%*" PRId64 "%10$s %9$s%3$c%4$s %5$s",
[radix_octal] = "%8$s%2$0*1$" PRIo64 "%10$s %9$s%3$c%4$s %5$s"
Note that 6$ and 7$ are missing, which is not allowed. With
_FORTIFY_SOURCE, glibc actually detects this condition and aborts.
printf is actually given all 10 arguments, and in another branch a
different set of formatting arguments are used, and those do contain 6$
and 7$. In the patch I reorder the arguments so that 6$ and 7$ become
9$ and 10$, and there are no gaps in any of the formatting strings.
Thanks,
PM
Show replies by date