Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Apr 2024 00:49:06 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ade62d406239 - stable/14 - __vprintf(): switch from strerror() to strerror_rl()
Message-ID:  <202404300049.43U0n6xX013085@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=ade62d406239b728a1c74974bbb57ed493c733e0

commit ade62d406239b728a1c74974bbb57ed493c733e0
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-04-23 17:10:30 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-04-30 00:48:10 +0000

    __vprintf(): switch from strerror() to strerror_rl()
    
    PR:     278556
    
    (cherry picked from commit f887667694632c829b0599b54ff86a072e93df87)
---
 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 38c77aebf316..0ce9d6f37569 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -315,6 +315,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 */
 
@@ -832,7 +834,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 : "<strerror failure>";
 			size = (prec >= 0) ? strnlen(cp, prec) : strlen(cp);
 			sign = '\0';
 			break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404300049.43U0n6xX013085>