The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f892e509c1a07f7116b9788a05e4ae99a06d54d0
commit f892e509c1a07f7116b9788a05e4ae99a06d54d0 Author: Konstantin Belousov <k...@freebsd.org> AuthorDate: 2025-08-19 03:05:37 +0000 Commit: Konstantin Belousov <k...@freebsd.org> CommitDate: 2025-08-19 21:22:40 +0000 libc: preserve errno in gai_strerror() PR: 288931 Reviewed by: emaste, glebius Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D52010 --- 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]);