getaddrinfo: translate ENOMEM to EAI_MEMORY (bug 31163)
authorAndreas Schwab <schwab@suse.de>
Wed, 6 Dec 2023 13:48:22 +0000 (14:48 +0100)
committerAndreas Schwab <schwab@suse.de>
Tue, 2 Jan 2024 10:10:42 +0000 (11:10 +0100)
When __resolv_context_get returns NULL due to out of memory, translate it
to a return value of EAI_MEMORY.

nss/getaddrinfo.c

index a225f9b..3ccd390 100644 (file)
@@ -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)
     {