getaddrinfo: translate ENOMEM to EAI_MEMORY (bug 31163)

Message ID mvmsf46ozhp.fsf@suse.de
State Committed
Commit 5eabdb6a6ac1599d23dd5966a37417215950245f
Headers
Series getaddrinfo: translate ENOMEM to EAI_MEMORY (bug 31163) |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed

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
  

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