git: ade62d406239 - stable/14 - __vprintf(): switch from strerror() to strerror_rl()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Apr 2024 00:49:06 UTC
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;