From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eastern.birch.relay.mailchannels.net (eastern.birch.relay.mailchannels.net [23.83.209.55]) by sourceware.org (Postfix) with ESMTPS id 4DB203858C74 for ; Tue, 4 Oct 2022 00:07:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4DB203858C74 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=sourceware.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 8F85B122EBC; Tue, 4 Oct 2022 00:07:20 +0000 (UTC) Received: from pdx1-sub0-mail-a305 (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id B92F6122F40; Tue, 4 Oct 2022 00:07:19 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1664842039; a=rsa-sha256; cv=none; b=NXW1ogXNft9JzdWSpvukN5ydJvpjOwGcQ4BiCL+njuQzEF7i61K2UUqmOmX+eFYJkeAMvq 378p5vW2ffYav1Xexb+ZL1yRWNj0JTzzVN9/MCuzfH6rzjHD/pCUWxYli3Nkzw1Fa8qygk H/BQSAy3BcJhmSdo+86O15hiJacMeDOgXiwgjVaG/+VnC5usnqki4+QZpq/xsMlrlCu4u6 6KmO8f7q54dkRGS50DWOScqF+93Yz7DBHDLUPbkzwliTQAWMlVX+0cIOonPC+BZoqzT+Aa mjAgye9lgyBxXH7ff5UIsXoJsONfYJPGbI0V1gloBTj2zBXqMezNVe+uY2gUrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1664842039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hh0L3Bw7Xrrw7MZn6wkI7/+gdoz2QheJPQqDBQpz2eE=; b=07Jxvv52VXNvta76hAHgHNm+fAlaXs49H+XcSun2Kw2WdyNLywAR1E0CABHoxywJl7pCw7 J5a9e9shFxPq5QRX129T0Nme49Wj3yOX7124pFbXW7zBAOxOPtGNuRg+HLbAi8xdamSe+q Vap3iOe1dacCd13PrI/FnVko/YUbFpbf+APZkAtWzOlIgkEqUOipHlLwcTKc7UtKHU1/uJ wk3e7ZJT7qv8fzoVL9rLpLD3I9D4qddQBNhDrcwhNY8PjD+8lkvWbSTuUROpkvwRUIN5GP z8qr/J0ATQUI2s24icX8KhB2ciX7YA2lZxiD6fEL8O8NZ1Me3L6nFjzizFqhvg== ARC-Authentication-Results: i=1; rspamd-6d4bb977-j7hpn; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Tasty-Interest: 473096df057daaac_1664842040195_3936977152 X-MC-Loop-Signature: 1664842040195:716206973 X-MC-Ingress-Time: 1664842040195 Received: from pdx1-sub0-mail-a305 (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.98.207.159 (trex/6.7.1); Tue, 04 Oct 2022 00:07:20 +0000 Received: from fedora.redhat.com (bras-vprn-toroon4834w-lp130-16-184-147-84-238.dsl.bell.ca [184.147.84.238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305 (Postfix) with ESMTPSA id 4MhJ130z7kzRW; Mon, 3 Oct 2022 17:07:19 -0700 (PDT) From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: =?UTF-8?q?Holger=20Hoffst=C3=A4tte?= Subject: [PATCH] nscd: Drop local address tuple variable [BZ #29607] Date: Mon, 3 Oct 2022 20:06:57 -0400 Message-Id: <20221004000657.1940145-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1173.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: When a request needs to be resent (e.g. due to insufficient buffer space), the references to subsequent tuples in the local variable are stale and should not be used. This used to work by accident before, but since 1d495912a it no longer does. Instead of trying to reset it, just let gethostbyname4_r write into TUMPBUF6 for us, thus maintaining a consistent state at all times. This is now consistent with what is done in gaih_inet for getaddrinfo. Resolves: BZ #29607 Reported-by: Holger Hoffstätte --- Tested on x86_64 with Fedora and nscd enabled. Testing with other distributions would be really appreciated! Thanks, Sid nscd/aicache.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nscd/aicache.c b/nscd/aicache.c index 51e793199f..e0baed170b 100644 --- a/nscd/aicache.c +++ b/nscd/aicache.c @@ -110,11 +110,10 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, "gethostbyname4_r"); if (fct4 != NULL) { - struct gaih_addrtuple atmem; struct gaih_addrtuple *at; while (1) { - at = &atmem; + at = NULL; rc6 = 0; herrno = 0; status[1] = DL_CALL_FCT (fct4, (key, &at, @@ -137,7 +136,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, goto next_nip; /* We found the data. Count the addresses and the size. */ - for (const struct gaih_addrtuple *at2 = at = &atmem; at2 != NULL; + for (const struct gaih_addrtuple *at2 = at; at2 != NULL; at2 = at2->next) { ++naddrs; -- 2.37.2