[PATCH] getaddrinfo: translate ENOMEM to EAI_MEMORY (bug 31163)

Andreas Schwab schwab@suse.de
Wed Dec 13 16:09:54 GMT 2023


When __resolv_context_get returns NULL due to out of memory, translate it
to a return value of EAI_MEMORY.
---
 nss/getaddrinfo.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/nss/getaddrinfo.c b/nss/getaddrinfo.c
index 6902a47224..b1cb4d7006 100644
--- a/nss/getaddrinfo.c
+++ b/nss/getaddrinfo.c
@@ -616,7 +616,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)
     {
-- 
2.43.0


-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


More information about the Libc-alpha mailing list