From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2206) id 9EF6F385C41F; Tue, 8 Mar 2022 14:10:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9EF6F385C41F 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: fcd3773d1cf506b76851463418231822c7f0cde5 X-Git-Newrev: b57bf811e56ede85a5c073331ca52380278bd10c Message-Id: <20220308141024.9EF6F385C41F@sourceware.org> Date: Tue, 8 Mar 2022 14:10:24 +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: Tue, 08 Mar 2022 14:10:24 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b57bf811e56ede85a5c073331ca52380278bd10c commit b57bf811e56ede85a5c073331ca52380278bd10c 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 eebed824a8..5cd988bec5 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; } }