Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Aug 2025 21:26:43 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f892e509c1a0 - main - libc: preserve errno in gai_strerror()
Message-ID:  <202508192126.57JLQheA048455@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=f892e509c1a07f7116b9788a05e4ae99a06d54d0

commit f892e509c1a07f7116b9788a05e4ae99a06d54d0
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-08-19 03:05:37 +0000
Commit:     Konstantin Belousov <kib@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]);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202508192126.57JLQheA048455>