git: 5e243ccc5f67 - stable/14 - libc: preserve errno in gai_strerror()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 26 Aug 2025 00:25:01 UTC
The branch stable/14 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=5e243ccc5f67229582f6e6cbfbaee834adb7cdae
commit 5e243ccc5f67229582f6e6cbfbaee834adb7cdae
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-08-19 03:05:37 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-08-26 00:23:31 +0000
libc: preserve errno in gai_strerror()
PR: 288931
(cherry picked from commit f892e509c1a07f7116b9788a05e4ae99a06d54d0)
---
lib/libc/net/gai_strerror.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/libc/net/gai_strerror.c b/lib/libc/net/gai_strerror.c
index 96bc32b593fa..23f58b763573 100644
--- a/lib/libc/net/gai_strerror.c
+++ b/lib/libc/net/gai_strerror.c
@@ -82,7 +82,9 @@ gai_strerror(int ecode)
#if defined(NLS)
nl_catd catd;
char *buf;
+ int saved_errno;
+ saved_errno = errno;
if (thr_main() != 0)
buf = gai_buf;
else {
@@ -110,9 +112,11 @@ gai_strerror(int ecode)
strlcpy(buf, catgets(catd, 3, NL_MSGMAX, "Unknown error"),
sizeof(gai_buf));
catclose(catd);
+ errno = saved_errno;
return (buf);
thr_err:
+ errno = saved_errno;
#endif
if (ecode >= 0 && ecode < EAI_MAX)
return (ai_errlist[ecode]);