]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
gethosts: Return EAI_MEMORY on allocation failure
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Wed, 2 Mar 2022 06:15:29 +0000 (11:45 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Fri, 15 Sep 2023 22:32:39 +0000 (18:32 -0400)
All other cases of failures due to lack of memory return EAI_MEMORY, so
it seems wrong to return EAI_SYSTEM here.  The only reason
convert_hostent_to_gaih_addrtuple could fail is on calloc failure.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit b587456c0e7b59dcfdbd2d44db000a3bc8244e57)

sysdeps/posix/getaddrinfo.c

index f5d4a5cfd90168fc50456fbaf2b72c59d090bea9..0ece3b46b700014579754ddae66ea11cd40db480 100644 (file)
@@ -303,13 +303,13 @@ gethosts (nss_gethostbyname3_r fct, int family, const char *name,
   else if (status == NSS_STATUS_SUCCESS)
     {
       if (!convert_hostent_to_gaih_addrtuple (req, family, &th, res))
-       return -EAI_SYSTEM;
+       return -EAI_MEMORY;
 
       if (localcanon != NULL && res->canon == NULL)
        {
          char *canonbuf = __strdup (localcanon);
          if (canonbuf == NULL)
-           return  -EAI_SYSTEM;
+           return  -EAI_MEMORY;
          res->canon = canonbuf;
        }
     }