getaddrinfo: Return correct error EAI_MEMORY when out-of-memory (RHEL-19444)

Resolves: RHEL-19444
This commit is contained in:
Arjun Shankar 2024-01-09 19:51:08 +01:00
parent b02eb10bf8
commit da346ff8a8
2 changed files with 34 additions and 1 deletions

29
glibc-RHEL-19444.patch Normal file
View File

@ -0,0 +1,29 @@
commit 5eabdb6a6ac1599d23dd5966a37417215950245f
Author: Andreas Schwab <schwab@suse.de>
Date: Wed Dec 6 14:48:22 2023 +0100
getaddrinfo: translate ENOMEM to EAI_MEMORY (bug 31163)
When __resolv_context_get returns NULL due to out of memory, translate it
to a return value of EAI_MEMORY.
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 321a6679d46494a3..8fe879c5420337a4 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -615,7 +615,14 @@ get_nss_addresses (const char *name, const struct addrinfo *req,
function variant. */
res_ctx = __resolv_context_get ();
if (res_ctx == NULL)
- no_more = 1;
+ {
+ if (errno == ENOMEM)
+ {
+ result = -EAI_MEMORY;
+ goto out;
+ }
+ no_more = 1;
+ }
while (!no_more)
{

View File

@ -155,7 +155,7 @@ end \
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 98%{?dist}
Release: 99%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries.
@ -806,6 +806,7 @@ Patch569: glibc-RHEL-16643-3.patch
Patch570: glibc-RHEL-16643-4.patch
Patch571: glibc-RHEL-16643-5.patch
Patch572: glibc-RHEL-16643-6.patch
Patch573: glibc-RHEL-19444.patch
##############################################################################
# Continued list of core "glibc" package information:
@ -2964,6 +2965,9 @@ update_gconv_modules_cache ()
%endif
%changelog
* Tue Jan 09 2024 Arjun Shankar <arjun@redhat.com> - 2.34-99
- getaddrinfo: Return correct error EAI_MEMORY when out-of-memory (RHEL-19444)
* Mon Jan 8 2024 Arjun Shankar <arjun@redhat.com> - 2.34-98
- getaddrinfo: Fix occasionally empty result due to nscd cache order (RHEL-16643)