Bug 14254 - __wur on scanf and related functions is wrong
Summary: __wur on scanf and related functions is wrong
Alias: None
Product: glibc
Classification: Unclassified
Component: stdio (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2012-06-16 11:05 UTC by Rich Felker
Modified: 2014-06-19 06:25 UTC (History)
1 user (show)

See Also:
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Rich Felker 2012-06-16 11:05:59 UTC
A perfectly valid idiom for using scanf-family functions is to include %n in your format string with the corresponding argument variables set in advance to -1 or similar (so that if the %n is not reached, the program can tell). This is particularly appropriate when the number of characters read, not the count of items read, is what's more interesting to the program.

As such, __wur (warn unused result) should be removed from all scanf-family functions.
Comment 1 Ondrej Bilka 2013-10-17 12:28:24 UTC
A %n usage is relatively rare and warnings are more useful.

As gcc does a type checking of scanf arguments you could ask gcc developers to selectively enable/disable wur based on %n presence.