From nobody Tue Nov 01 00:46:30 2022 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 4N1WYM0Fsqz4gxxR; Tue, 1 Nov 2022 00:46:31 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N1WYL5L9qz3Qtf; Tue, 1 Nov 2022 00:46:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667263590; 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=xN8+UaNcqv8zQS9pLvcGf74xvqBqsKroFNGqEkkvsn0=; b=U2tWBqAChGN6uWqa6RpsAx8gwa0vyCOdJNbHH1Hx0VJF2DgQL/qt+oY9fcHRQcqVexHh8u MKpHpFoThojv2eKurXGRqz3nt46BlN6gN2RuZZt+yVKDc0q91qUY9FS2fAnkQ/tvfUYRqW EYv5Um5eX506GtmpZWWzTRREi7xvysdhvua+09cuqeGltPJh/i0LLMpC6M7k7eFdIi1ZJY JE6CX0BTq4fnKMI/ad/VhdXm7/EuVJJa8pMA8Nzh2MsiWz+pSGqbJj6rif9pj0f2xPXT8s N1wjV3Xp2vBxnPnNjqHJ36wkF+lYzsyM3NbjeJTwn9+qKpMl5KOZLqwzRJUoEg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N1WYL4RgJzwWs; Tue, 1 Nov 2022 00:46:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2A10kUx1042002; Tue, 1 Nov 2022 00:46:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A10kU68042001; Tue, 1 Nov 2022 00:46:30 GMT (envelope-from git) Date: Tue, 1 Nov 2022 00:46:30 GMT Message-Id: <202211010046.2A10kU68042001@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: da5b1c42c5aa - stable/13 - strfmon: Avoid an out-of-bounds access 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: da5b1c42c5aa6f2b4fe717ba50bf4780945fa8ca Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667263590; 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=xN8+UaNcqv8zQS9pLvcGf74xvqBqsKroFNGqEkkvsn0=; b=qx00gswyOW29YUiQwe8u0eN0Lqgz8XxbVV48rqK4kzsS/T0qC/H7Nd+ZTlXva+Yt7r1W1F rztrMqcVPXGFwjRIkpsk//9KjncGoniN4gT7oWssYyMBcZk6IILwvr5HrM6VnQsNFvYWdq 8Ujan50sDL1UEKV3ISLIzoBzyfa9tIMk1iE30lwFfcCNkHzxfxOHE4VQ60IIqyHwJZJwdC VqvCuNbAYeYUPWbSNOf8Oev/HBAowF3SXz7s4rYRTHQewzB6q4v5gNSkHZoaTvNhJfDEGS UPzwfB6wP4mCGzViq6TZgZOOcfdW1PrnR8wP184l9moCpRRk80Ws/vlniqgrmw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667263590; a=rsa-sha256; cv=none; b=sAAEmMi0BjJTNLWuD88PonVONAFrtrlAa5w7bRI8l7oSo5pmyhQKwxY6FesQQMtHgq9+6+ lanZAB2kuPmHjRYyF09lUpWY/sC44dtoIqY4yZtiHeYuFVXUbkJN3ztM8zUU3SImOS11Os glZh9cJom7gmpOA03YsnymuuhlvZ92VVnX2E17nnubN2MxSmeABic+yE4X7kHoaOaIc036 0gaGvpAmPCza71aQ3sT0MISbH8Cyy6C9wKfZORZuB4Kuu/6moAwFs06qkcQWH2aVyPEkHm hzUekavK4cWt4+NpYEwIwICUCguq7lXxH5iADaCs0Gc9wDJCziwd2AGm7KJDQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=da5b1c42c5aa6f2b4fe717ba50bf4780945fa8ca commit da5b1c42c5aa6f2b4fe717ba50bf4780945fa8ca Author: Jose Luis Duran AuthorDate: 2022-10-13 15:51:27 +0000 Commit: Konstantin Belousov CommitDate: 2022-11-01 00:44:41 +0000 strfmon: Avoid an out-of-bounds access (cherry picked from commit 9e03b903e377c75a60cbbb89ed78955769a1c804) --- lib/libc/stdlib/strfmon.c | 5 +++-- lib/libc/tests/stdlib/strfmon_test.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c index db51325bff9e..0f327585f5a2 100644 --- a/lib/libc/stdlib/strfmon.c +++ b/lib/libc/stdlib/strfmon.c @@ -239,8 +239,9 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc, free(currency_symbol); if (flags & USE_INTL_CURRENCY) { currency_symbol = strdup(lc->int_curr_symbol); - if (currency_symbol != NULL) - space_char = *(currency_symbol+3); + if (currency_symbol != NULL && + strlen(currency_symbol) > 3) + space_char = currency_symbol[3]; } else currency_symbol = strdup(lc->currency_symbol); diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c index 3e77a4f5290f..dc328e974bb8 100644 --- a/lib/libc/tests/stdlib/strfmon_test.c +++ b/lib/libc/tests/stdlib/strfmon_test.c @@ -197,7 +197,7 @@ ATF_TC_BODY(strfmon_international_currency_code, tc) } tests[] = { { "en_US.UTF-8", "[USD 123.45]" }, /* XXX */ { "de_DE.UTF-8", "[123,45 EUR ]" }, /* XXX */ - { "C", "[123.45]" }, /* XXX OOB access */ + { "C", "[123.45]" }, }; size_t i; char actual[100];