From nobody Wed Nov 26 20:35:37 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 4dGrt15TmZz6HPmn for ; Wed, 26 Nov 2025 20:35:37 +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 4dGrt13Yphz3SCM for ; Wed, 26 Nov 2025 20:35:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764189337; 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=ZhYuXlgqPg888J96PJYX2MTFNqpEYjBGySCeqrTg7F8=; b=Fmc8xeYmITb+ptywQ35XxC9hPwPX0HTd+ph4mGBYxeoA9fVfLS4wxCDzCRZrypfDhb+feT EHNH+GX9bTm33AXaImvVqV3vbfV7L6mWPJy6CCCDoXSiZZK9RfS+3AyzI1iCAvffMaUqQ6 /23w3QoMysmaYfxHyQxupu5hLkFaOIdUUERlO2C+URkn7BYumUtMcpsRiydccFj1qyc3AV b9ixUxDoTbpUsNc7PT1ywLphdOjDcUjEepJ0H8aRrpq2IddcPtH2DsfPWtxpDpaBlegvho Vlm7CI+7yP8rPkalkmlhsPnzAObKKF0MqJwSDVUmY5C5KTe7Ta1z//DGkIk7vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764189337; 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=ZhYuXlgqPg888J96PJYX2MTFNqpEYjBGySCeqrTg7F8=; b=Lauw/Bc3de/1U+5HdZCdalEQmyDijme0rGGz7tVXXawyfHJnW+302+Uqq96blJbu9sa1GJ dqgpKMjdIyqLrTmobYM4V/aMDvw+sA7kwpwzEMXj9DrwmuRXNFGlSVCZRQXws9LIemfj/M szP6HkY2uPLHHLN9aL1QMjxoULiPl0N3u8G4zylEhxgPkIVMrZJyayh0jM9Fwb/W1lpTSj BkJ4tOYSiOpfJAMe5t1S9qg4DvSjLwGiQqZ1ovFZLuIlVGUVL6Os7WOhGz+mmlQpvv8/2E w40G+dkUTuCL42yzrD/jtnB/bXpAxxRyzOp+Trb1TnMcxA0o/d+GJcYQrBHHfw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1764189337; a=rsa-sha256; cv=none; b=t9kS9vNiIfkjqWl7EkrO7tFFwgOs7S7F/rlDRQ/DD9dBUYT246qwM4d2cHjh9mtJRVlpTa UIO3qyBOuvClU4Fs+YGQ2Fastck02yoeJYwPeTpzziatlvGqf/PYUTisNL1m08Dxy6HVo0 URyAjuVb0/len3jei+YGwgprDStjkThv+Kis5dokcXyEQdQ1yE1RaLwi0v4d/9ftPKNd3A 8RTbFAlWUfdHFBJd3/htyqPqnG//4wzfk5UNwf+RxyIIUQ4vc9y796Ev9G4rKWxIbPfRb1 DQ5SKQUoZ2pYrBF1QswnT8G4N2R29/vnoibyJtWs8MLe43vl92HJfPsAOOKcCw== 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 4dGrt135MHz12CD for ; Wed, 26 Nov 2025 20:35:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2ed7b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 26 Nov 2025 20:35:37 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jose Luis Duran Subject: git: 1fd018972a18 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 1fd018972a18b682521bb8f004dfd162327e5db2 Auto-Submitted: auto-generated Date: Wed, 26 Nov 2025 20:35:37 +0000 Message-Id: <69276499.2ed7b.2ef50b70@gitrepo.freebsd.org> The branch main has been updated by jlduran: URL: https://cgit.FreeBSD.org/src/commit/?id=1fd018972a18b682521bb8f004dfd162327e5db2 commit 1fd018972a18b682521bb8f004dfd162327e5db2 Author: Jose Luis Duran AuthorDate: 2025-11-26 20:34:55 +0000 Commit: Jose Luis Duran CommitDate: 2025-11-26 20:34:55 +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 --- 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);