From nobody Tue Apr 23 19:44:24 2024 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 4VPCHX5v0yz5Hx3n; Tue, 23 Apr 2024 19:44:24 +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 4VPCHX3WNwz4hC1; Tue, 23 Apr 2024 19:44:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713901464; 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=1Ek64r5YuK5HCM8ITy49MLljM4JYWUp0au6GvsUpuLU=; b=lO27iK6ArDXsaPPIkWkk1wvE4T3eiICRgyXA4iZhI20T0lMqYKPM5jw0RA0kxoj6h4T9TJ fkmQvHZrYEWXqUeMxzonaF6OXp5ZQy+5RHnUDdiVzZTND25BiZrBgQ/9W8njZUcFSiz/MW eCfDV7QQNo27XNwal7kYCWBLvr34InPGNNLBCMkNlXlvpb5I68TzkVDnMphMDoHuUYq3+d 7jK2tOzuvEe7HsthHlAYQVdLil4AZuKPmkwRBG7Rw4MbmIns7JZy2j9sHfGgmZArxgfqBQ pZJbFaVvAw8QpKkdJNTPZtBOSFkXCA2QVvS6st5wFgR/gv75y3UuWmfB3kum/Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713901464; a=rsa-sha256; cv=none; b=EYVHUrX83U29H0Jwt8uEzp5kVhsJP5ri1pPSwCR0HjzH3eJkAqSn9cjMXvb76e0HxpshOj pHP05xhtGRZN7ET6pooXg/xQTbWwSJdRi8aVXZZL20VNo1uGmec+4jWj2OIuoeI3JqpJeW AJwCbqyxh5vriWEXUSYKIi8a7gCzXGx6ED7yLWtvggw8tOc0evGuB8H+5JGm08CI0UYHBi 19Ttsq8cP6Zsjk45c2aBJyWAAnUXXCp2C/I9799g6BBFQitqei7P4u4qH8NiJFLMYmwt18 /4Gs7xSp4Q2WFPYoFsU83+7ClBuZYR135qX1XPNLdNe6T0mM408wMAwDLk8OyA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713901464; 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=1Ek64r5YuK5HCM8ITy49MLljM4JYWUp0au6GvsUpuLU=; b=QHCYAxTQhB55NJpRDq1tBtC1e2p+O6rxQXNnMUao3KH4VxaiWmUhjBnauN0hoIQpXSuYfR REuLPy572IQz4tbRGo8BEBOwFd4X7qlgy4nRGU0FsfYuOGeDDU0fMrB+cIs8wzfA6/SA64 ke3E7RclGjZ2fesLr76XWv9i8tC/Ld6/X8q76dzirfPLK9FRgohXhOotJ4rhBxIzlBtNln JFtCDhrjhR9VAeGwC5IPSOOM07f6V0NfYJSV8dsqeqWk/ofmmdayDVmoBq/IVs4IDYI3Aj 1x7XEGEyLa1luwfDhLfLSJctKErc1YJiGxD+W1FNMnCzXFbfX+5JPmoO2N3qtA== 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 4VPCHX37TSzl8c; Tue, 23 Apr 2024 19:44:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43NJiOvm077546; Tue, 23 Apr 2024 19:44:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43NJiOhl077543; Tue, 23 Apr 2024 19:44:24 GMT (envelope-from git) Date: Tue, 23 Apr 2024 19:44:24 GMT Message-Id: <202404231944.43NJiOhl077543@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f88766769463 - main - __vprintf(): switch from strerror() to strerror_rl() 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f887667694632c829b0599b54ff86a072e93df87 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f887667694632c829b0599b54ff86a072e93df87 commit f887667694632c829b0599b54ff86a072e93df87 Author: Konstantin Belousov AuthorDate: 2024-04-23 17:10:30 +0000 Commit: Konstantin Belousov CommitDate: 2024-04-23 19:43:01 +0000 __vprintf(): switch from strerror() to strerror_rl() This eliminates the use of non-thread-safe function in printf*() family, and make the call locale-aware. Also, it stops obliterating the strerror() static buffer, which aligns with the POSIX requirement that implementations must behave as if no standard-mandated functions call strerror(). PR: 278556 Reported by: Jonathan Gruber Reviewed by: imp Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44916 --- lib/libc/stdio/vfprintf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 6c7c6982c8dc..7048315a8d78 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -312,6 +312,8 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap) int width; /* width from format (%8d), or 0 */ int prec; /* precision from format; <0 for N/A */ int saved_errno; + int error; + char errnomsg[NL_TEXTMAX]; char sign; /* sign prefix (' ', '+', '-', or \0) */ struct grouping_state gs; /* thousands' grouping info */ @@ -829,7 +831,9 @@ fp_common: break; #endif /* !NO_FLOATING_POINT */ case 'm': - cp = strerror(saved_errno); + error = __strerror_rl(saved_errno, errnomsg, + sizeof(errnomsg), locale); + cp = error == 0 ? errnomsg : ""; size = (prec >= 0) ? strnlen(cp, prec) : strlen(cp); sign = '\0'; break;