git: 09bcfbd1aede - stable/14 - libc printf_render_errno(): do not use strerror()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Apr 2024 00:49:08 UTC
The branch stable/14 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=09bcfbd1aede8f7596f14a95fd408aa79a239a9c
commit 09bcfbd1aede8f7596f14a95fd408aa79a239a9c
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-04-23 17:15:22 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-04-30 00:48:10 +0000
libc printf_render_errno(): do not use strerror()
(cherry picked from commit aa66995b4c804cbb579f71645d97fe282a798bfc)
---
lib/libc/stdio/xprintf_errno.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/libc/stdio/xprintf_errno.c b/lib/libc/stdio/xprintf_errno.c
index c63a7afd35e0..f1e5421f60c8 100644
--- a/lib/libc/stdio/xprintf_errno.c
+++ b/lib/libc/stdio/xprintf_errno.c
@@ -27,6 +27,7 @@
*/
#include <namespace.h>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -53,13 +54,13 @@ __printf_render_errno(struct __printf_io *io, const struct printf_info *pi
{
int ret, error;
char buf[64];
- const char *p;
+ char errnomsg[NL_TEXTMAX];
ret = 0;
error = *((const int *)arg[0]);
if (error >= 0 && error < __hidden_sys_nerr) {
- p = strerror(error);
- return (__printf_out(io, pi, p, strlen(p)));
+ strerror_r(error, errnomsg, sizeof(errnomsg));
+ return (__printf_out(io, pi, errnomsg, strlen(errnomsg)));
}
sprintf(buf, "errno=%d/0x%x", error, error);
ret += __printf_out(io, pi, buf, strlen(buf));