Page MenuHomeFreeBSD

strfmon: EINVAL if the '+' flag and both signs are empty
ClosedPublic

Authored by jlduran on Wed, Nov 26, 2:52 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 18, 1:04 PM
Unknown Object (File)
Thu, Dec 18, 7:46 AM
Unknown Object (File)
Mon, Dec 15, 9:15 PM
Unknown Object (File)
Mon, Dec 15, 3:03 PM
Unknown Object (File)
Mon, Dec 8, 7:55 AM
Unknown Object (File)
Sun, Nov 30, 12:15 AM
Subscribers

Details

Summary

According to the Open Group Base Specifications Issue 8[1], strfmon(3)
should return EINVAL when the '+' flag was included in a conversion
specification and the locale's positive_sign and negative_sign values
would both be returned by localeconv(3) as empty strings.

Austin Group Defect 1199[2] is applied, adding the [EINVAL] error.

[1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html
[2]: https://www.austingroupbugs.net/view.php?id=1199

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/libc/stdlib/strfmon.c
174–176

Why this is || and not &&?

lib/libc/stdlib/strfmon.c
174–176

I believe the confusion stems from the fact that SIGN_POSN_USED means either + or ( is used, not that just + is used:
For example, if a ( has already been used, e.g., %(+n, it should return EINVAL, regardless of the sign positive numbers (the current explanation on the manual page for returning EINVAL).
The new possibility for returning EINVAL would be if both positive_sign and negative_sign are "", e.g., the C locale, as discussed in:
https://www.austingroupbugs.net/view.php?id=1199
The second explanation for returning EINVAL (added in this commit).

This revision is now accepted and ready to land.Wed, Nov 26, 5:03 PM