diff options
| author | Jose Luis Duran <jlduran@FreeBSD.org> | 2025-11-26 20:34:55 +0000 |
|---|---|---|
| committer | Jose Luis Duran <jlduran@FreeBSD.org> | 2025-12-03 02:34:21 +0000 |
| commit | 8dc8e3011d05bdadb3e62fe99fbb054e33bfd8f2 (patch) | |
| tree | a518d466d6e8453d914392e5b560e95be2469b93 /lib/libc/stdlib | |
| parent | 7745ece2819e3613308974c5c547b7d1218b3856 (diff) | |
Diffstat (limited to 'lib/libc/stdlib')
| -rw-r--r-- | lib/libc/stdlib/strfmon.3 | 12 | ||||
| -rw-r--r-- | lib/libc/stdlib/strfmon.c | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/libc/stdlib/strfmon.3 b/lib/libc/stdlib/strfmon.3 index 20cc560d401d..d537d9d05fa7 100644 --- 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 @@ function will fail if: 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 index 230d194233f5..b19d9fc43369 100644 --- a/lib/libc/stdlib/strfmon.c +++ b/lib/libc/stdlib/strfmon.c @@ -171,7 +171,9 @@ literal: 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; |
