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

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

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 IST
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 IST
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.