public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@sourceware.org>
To: libc-stable@sourceware.org
Cc: DJ Delorie <dj@redhat.com>
Subject: [pushed 2.34 13/14] gethosts: Return EAI_MEMORY on allocation failure
Date: Fri, 15 Sep 2023 20:49:00 -0400	[thread overview]
Message-ID: <20230916004902.1151607-14-siddhesh@sourceware.org> (raw)
In-Reply-To: <20230916004902.1151607-1-siddhesh@sourceware.org>

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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 1008f24736..37260d6e6f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -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;
 	}
     }
-- 
2.41.0


  parent reply	other threads:[~2023-09-16  0:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-16  0:48 [pushed 2.34 00/14] Backport gaih_inet refactoring and CVE fix Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 01/14] nss: Sort tests and tests-container and put one test per line Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 02/14] gethosts: Remove unused argument _type Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 03/14] gaih_inet: Simplify canon name resolution Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 04/14] getaddrinfo: Fix leak with AI_ALL [BZ #28852] Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 05/14] gaih_inet: Simplify service resolution Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 06/14] gaih_inet: make numeric lookup a separate routine Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 07/14] gaih_inet: Split simple gethostbyname into its own function Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 08/14] gaih_inet: Split nscd lookup code " Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 09/14] gaih_inet: separate nss lookup loop " Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 10/14] gaih_inet: make gethosts into a function Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 11/14] gaih_inet: split loopback lookup into its own function Siddhesh Poyarekar
2023-09-16  0:48 ` [pushed 2.34 12/14] gaih_inet: Split result generation " Siddhesh Poyarekar
2023-09-16  0:49 ` Siddhesh Poyarekar [this message]
2023-09-16  0:49 ` [pushed 2.34 14/14] getaddrinfo: Fix use after free in getcanonname (CVE-2023-4806) Siddhesh Poyarekar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230916004902.1151607-14-siddhesh@sourceware.org \
    --to=siddhesh@sourceware.org \
    --cc=dj@redhat.com \
    --cc=libc-stable@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).