Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151923150
D53912.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D53912.id.diff
View Options
diff --git a/lib/libc/stdlib/strfmon.3 b/lib/libc/stdlib/strfmon.3
--- a/lib/libc/stdlib/strfmon.3
+++ b/lib/libc/stdlib/strfmon.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 6, 2023
+.Dd November 24, 2025
.Dt STRFMON 3
.Os
.Sh NAME
@@ -182,6 +182,16 @@
Conversion stopped due to lack of space in the buffer.
.It Bq Er EINVAL
The format string is invalid.
+.It Bq Er EINVAL
+The
+.Cm +
+flag was included in a conversion specification and the locale's
+.Va positive_sign
+and
+.Va negative_sign
+values would both be returned by
+.Xr localeconv 3
+as empty strings.
.It Bq Er ENOMEM
Not enough memory for temporary buffers.
.El
diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c
--- a/lib/libc/stdlib/strfmon.c
+++ b/lib/libc/stdlib/strfmon.c
@@ -171,7 +171,9 @@
flags &= ~(NEED_GROUPING);
continue;
case '+': /* use locale defined signs */
- if (flags & SIGN_POSN_USED)
+ if ((flags & SIGN_POSN_USED) ||
+ ((lc->positive_sign[0] == '\0') &&
+ (lc->negative_sign[0] == '\0')))
goto format_error;
flags |= (SIGN_POSN_USED | LOCALE_POSN);
continue;
diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c
--- a/lib/libc/tests/stdlib/strfmon_test.c
+++ b/lib/libc/tests/stdlib/strfmon_test.c
@@ -234,11 +234,11 @@
if (setlocale(LC_MONETARY, "C") == NULL)
atf_tc_skip("unable to setlocale(): %s", tests[i].locale);
- /* ATF_CHECK_ERRNO(EINVAL, strfmon(actual, sizeof(actual) - 1,
- "[%+n] [%+n]", 123.45, -123.45)); XXX */
+ ATF_CHECK_ERRNO(EINVAL, strfmon(actual, sizeof(actual) - 1,
+ "[%+n] [%+n]", 123.45, -123.45));
- /* ATF_CHECK_ERRNO(EINVAL, strfmon(actual, sizeof(actual) - 1,
- "[%+i] [%+i]", 123.45, -123.45)); XXX */
+ ATF_CHECK_ERRNO(EINVAL, strfmon(actual, sizeof(actual) - 1,
+ "[%+i] [%+i]", 123.45, -123.45));
}
ATF_TC(strfmon_l);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 12, 1:31 PM (15 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31350845
Default Alt Text
D53912.id.diff (1 KB)
Attached To
Mode
D53912: strfmon: EINVAL if the '+' flag and both signs are empty
Attached
Detach File
Event Timeline
Log In to Comment