git: 27e54c9f1628 - stable/13 - __vprintf(): switch from strerror() to strerror_rl()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Apr 2024 00:50:22 UTC
The branch stable/13 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=27e54c9f162879fcbf6f1d9dc221b98c8180f012
commit 27e54c9f162879fcbf6f1d9dc221b98c8180f012
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:49:53 +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 ad655c5d78d4..e656a2707d3a 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -316,6 +316,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 */
@@ -777,7 +779,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;