From nobody Wed Dec 3 02:38:07 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dLhdX0rvfz6Jfky for ; Wed, 03 Dec 2025 02:38:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dLhdW6s8nz3rLc for ; Wed, 03 Dec 2025 02:38:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764729488; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WBuT4cMYap4EBrURY0vOM74cEsn8ektI+eYPW4une+c=; b=YHke2bVcXijMNk8zSTm/Z3WQxZDYlgMQupPUJF/XvCQQXGiP/JiH9Bo8Fa4x3m5rIPZtf5 aWVvF8FfhNknoTMgnQQ8MThmmy/xlHj1VnFDZr/uBRDQzzWrMDN+Jkl0Ubqe6c9lQdDvps Tg5AqLZQm/kYHdd2boLQwd3NFLLh/JVpTeLZ29beCLXaq7ITb8huH2cs0QWG6jMreZ/YeZ jfh+Y1iTFdUbK1OtxD87EJqsWpRfcQnR2sIh53eTetoKqKi3Eog7Odfo6CB+VqXkm1QLgo prQhLaHnwoMMaO3drUpcUrCi4hyDM4kqc1ZFqFThQvFF6w/+DlJ7vnfMY8VZxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764729488; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WBuT4cMYap4EBrURY0vOM74cEsn8ektI+eYPW4une+c=; b=WwczwEAcIHHhZicMpJVxLu4g1FdcYXDz68VbLZl14aLB6KbLkJQIBzoiO2njdwzxPQkRT4 mJNYkx313iHXU+hlZC76abdmNLixzF2vRWht79/1pvjnjxAyeGkg1u4JGdcfXfN9wmN1Lu LSkfpbtRluIIrslC7ija087Cx4PRHar6WOm5gtIpop/oIxbjcaIkH+0elyeHt1yG42vm6O osAgTv3QotCdmsaNAdtRaNb7WAebONf7YJ9mAxiUKW6M/ogr70xHP6X2HQ/kY5RL3O9wjT ShQeTzDtHK1vAOHv7r8NF951RmpyNboX1SBZivkWDY/hh4R+G/2EJcssvrAlOQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1764729488; a=rsa-sha256; cv=none; b=v+KqxowBXHzkNY4ImKBxdv5SvSDfXCoUQos14MNESM24oawxqRbj/0gGYk4zYnNwrd4ZZV oZ10bHfeVi0DacxOyJTD1N3pmnjL9Ekqt4K1uSLp19FDz3IdxsY2ET8e0iGf5+KL1eGLJ0 Lsion9+XvEiaEdXpo2W6l2N1Nm2KgGPlJOhg9h1SWjDQQjDihc6Blfk0B5d0wyH4wRFWRC hbJv0UyP/9m6Vy1w8AZqUedptXDVhzgn+qm2GGKSUw/0RSEv3DeUAc7cy1La0cm7qygInp Csnncvif30Y3yforB7QecPsDdjJi1a567bcL6hXDuhpBvxCl9Kuvf/eAke6osA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dLhdW6P4Mz3QF for ; Wed, 03 Dec 2025 02:38:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2f7ab by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 03 Dec 2025 02:38:07 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jose Luis Duran Subject: git: 488c4a511434 - stable/15 - strfmon: EINVAL if the '+' flag and both signs are empty List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jlduran X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 488c4a511434c9f72729846163e04b265cb9d170 Auto-Submitted: auto-generated Date: Wed, 03 Dec 2025 02:38:07 +0000 Message-Id: <692fa28f.2f7ab.1a30038b@gitrepo.freebsd.org> The branch stable/15 has been updated by jlduran: URL: https://cgit.FreeBSD.org/src/commit/?id=488c4a511434c9f72729846163e04b265cb9d170 commit 488c4a511434c9f72729846163e04b265cb9d170 Author: Jose Luis Duran AuthorDate: 2025-11-26 20:34:55 +0000 Commit: Jose Luis Duran CommitDate: 2025-12-03 02:28:53 +0000 strfmon: EINVAL if the '+' flag and both signs are empty 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 Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53912 (cherry picked from commit 1fd018972a18b682521bb8f004dfd162327e5db2) --- lib/libc/stdlib/strfmon.3 | 12 +++++++++++- lib/libc/stdlib/strfmon.c | 4 +++- lib/libc/tests/stdlib/strfmon_test.c | 8 ++++---- 3 files changed, 18 insertions(+), 6 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; diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c index 3c97d61ba82c..165ddcc2ab56 100644 --- a/lib/libc/tests/stdlib/strfmon_test.c +++ b/lib/libc/tests/stdlib/strfmon_test.c @@ -234,11 +234,11 @@ ATF_TC_BODY(strfmon_plus_or_parenthesis, tc) 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);