From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2206) id DA5563858D39; Wed, 2 Mar 2022 06:34:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA5563858D39 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Siddhesh Poyarekar To: glibc-cvs@sourceware.org Subject: [glibc/siddhesh/gai-cleanup2] gethosts: Return EAI_MEMORY on allocation failure X-Act-Checkin: glibc X-Git-Author: Siddhesh Poyarekar X-Git-Refname: refs/heads/siddhesh/gai-cleanup2 X-Git-Oldrev: f66eb74240baa93a5a06eed517322d9a4a131ed4 X-Git-Newrev: 5cbcab03883ec7421fb59d0c79928e878077802b Message-Id: <20220302063449.DA5563858D39@sourceware.org> Date: Wed, 2 Mar 2022 06:34:49 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Mar 2022 06:34:50 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5cbcab03883ec7421fb59d0c79928e878077802b commit 5cbcab03883ec7421fb59d0c79928e878077802b Author: Siddhesh Poyarekar Date: Wed Mar 2 11:45:29 2022 +0530 gethosts: Return EAI_MEMORY on allocation failure 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 Diff: --- 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 f790921487..f89169dd33 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -326,7 +326,7 @@ gethosts (nss_gethostbyname3_r fct, const int family, const char *name, { if (!convert_hostent_to_gaih_addrtuple (req, family, &th, &addrmem)) { - result = -EAI_SYSTEM; + result = -EAI_MEMORY; goto out; } if (addrmem && !gaih_lookup_result_push_alloc (res, addrmem)) @@ -339,7 +339,7 @@ gethosts (nss_gethostbyname3_r fct, const int family, const char *name, char *canonbuf = __strdup (localcanon); if (canonbuf == NULL) { - result = -EAI_SYSTEM; + result = -EAI_MEMORY; goto out; } *canonp = canonbuf;