diff mbox series

getaddrinfo: translate ENOMEM to EAI_MEMORY (bug 31163)

Message ID mvmsf46ozhp.fsf@suse.de
State New
Headers show
Series getaddrinfo: translate ENOMEM to EAI_MEMORY (bug 31163) | expand

Commit Message

Andreas Schwab Dec. 13, 2023, 4:09 p.m. UTC
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(-)

Comments

Florian Weimer Dec. 20, 2023, 4:12 p.m. UTC | #1
* Andreas Schwab:

> 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;
> +    }

Looks good, thanks.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Florian
diff mbox series

Patch

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)
     {