-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
Description
I understand the printf api is not recommended for new usage. I'm migrating an older codebase from a custom formatting utility over printf to using fmtlib for binary size wins. There is one test case which correctly identifies a failing case in fmtlib which I am reporting in case it is interesting or useful.
fmt::printf("%6$-*5$.*4$f%3$s%2$s%1$s", "", "", "", 7, 4, 100.44); returns width is not integer.
::printf("%6$-*5$.*4$f%3$s%2$s%1$s", "", "", "", 7, 4, 100.44) prints 100.4400000.
This appears to be because when fmt handles the '*5%' specifier it does not recognize the positional argument and so tries to fetch the -1st arg, which is out of bounds and causes a wild read.