From patchwork Mon Oct 30 18:57:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Palus X-Patchwork-Id: 1857207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fastmail.com header.i=@fastmail.com header.a=rsa-sha256 header.s=fm3 header.b=HFJUj4C2; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=M0ZSaAZe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SK2ZS5MtCz1yQW for ; Tue, 31 Oct 2023 05:57:20 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E6203858D38 for ; Mon, 30 Oct 2023 18:57:18 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by sourceware.org (Postfix) with ESMTPS id B86343858D1E for ; Mon, 30 Oct 2023 18:57:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B86343858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=fastmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=fastmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B86343858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=64.147.123.24 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698692231; cv=none; b=ZYUyBg6H5Uc3rHD1yDUuEGRhuZseBswXzDWYq8yY+51RjCH/i9Hu9dPNz+krneQiCPT69iq4qt0y6+Nwup6+MK7fUjw4eS1ID5YfnkFzpaZO7zxAjrJJ5F+XwV231gWaxyFLvxxxsa7y1aW79ZZaLMaqIzcujscwiwaPKlr3o4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698692231; c=relaxed/simple; bh=w7unECbycBOLL6RWk4i3J4GaOzoVnoP7lXHk3Af15Jc=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=AX0VZyBxYHxmYHErPyLy/ESZG73N8cb6jGYAdLRjsaj4ayI3Ypjx+ZfHrTG3YtBNk/FanA48W63DjT4xlIzF9NqGCm80m3iNOHpXhme9kuQbyexAfXeqYS6aKNmFuaZxKCrVePBxH2EK7Mjy9R8Y5yH2mfYYDAdNhFzfpC3wIpI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 4C94932008FB; Mon, 30 Oct 2023 14:57:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 30 Oct 2023 14:57:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm3; t=1698692227; x=1698778627; bh=guL78+T9BI p5i/wrnKgjYM3fzozLqfuEoI6zZI4QN9Q=; b=HFJUj4C29/+fwDKVpFj48kjYfu znf4hyegfOQ2+AezWXiZHz9RZXY0px//5VsnoZEdBQrmIAOcFpsLX/aX7wztk9P2 h8Z1ACpC8DFy6XOZAZ1DKjOKHJI2Q/ObOZ/xWqwAx3YERnimqGiS6nIVIcHiiA77 g62s99zbtg1V8FwdHQ+X3k14sGzObD1pcK9EozyIZ17R/ogeUenK+TziDjCuQU8J lew6+OMZCCkJZbGbFRL7S3oPQiZ7HDA7CSRHOshKJqYMhzp/XXghvO3iJzTlMsV0 ymoOateYBHDODy5HkC7bxSm7aByE0AiKjwQ1vZJfKMnpQQ/FkvUiJBeU35Fg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1698692227; x=1698778627; bh=guL78+T9BIp5i /wrnKgjYM3fzozLqfuEoI6zZI4QN9Q=; b=M0ZSaAZe8gCKBKxXLzV8rEw2YFCtf 85KggLB+VR2oiZZPGxK4iZ+tk/tljRdwByfHLJG02b/Pgt+Ydylqd9sfDFZqz/S/ sFP0eEmX0pXEsqcGGprSmEKSu82HKWLChdW90xM2ZNxVlS3tRssjar7r8IMpPxSE Ucau03KyilenOZYp4KEuQaBa40O7ub9at3hHp1mLk3PTiBLgPo49tc0cXvjYB44d TbEIfcIMgxH6K8KEF2Qp3ymzJCQJhkQq+7PdlBvh7omkO6RTs45wUc69ytFZr4cz oqWgwI08cyqge8EpJufSwfw+w4ab/8Svd60k8p9IBdnzWCIlJwjdGJuTg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddttddguddujecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgggfestdekre dtredttdenucfhrhhomheplfgrnhcurfgrlhhushcuoehjphgrlhhushesfhgrshhtmhgr ihhlrdgtohhmqeenucggtffrrghtthgvrhhnpefhkedvvdegkefhjeduieevueeihfduke ehjefhleehudfhhfelgefgtedtteeutdenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehjphgrlhhushesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: i01894241:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 Oct 2023 14:57:07 -0400 (EDT) From: Jan Palus To: libc-alpha@sourceware.org Cc: Jan Palus Subject: [PATCH] resolv: free only initialized items from gai pool Date: Mon, 30 Oct 2023 19:57:01 +0100 Message-ID: <20231030185701.639111-1-jpalus@fastmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org pool_max_size denotes total allocated rows in pool but possibly not yet initialized. it's pool_size that represents number of actually occupied rows hence use it when freeing pool to avoid freeing random addresses. Signed-off-by: Jan Palus Reviewed-by: Florian Weimer --- resolv/gai_misc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resolv/gai_misc.c b/resolv/gai_misc.c index d02bd7ed23..266ed6931c 100644 --- a/resolv/gai_misc.c +++ b/resolv/gai_misc.c @@ -1,4 +1,5 @@ /* Copyright (C) 2001-2023 Free Software Foundation, Inc. + Copyright The GNU Toolchain Authors. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -442,7 +443,7 @@ __gai_freemem (void) { size_t row; - for (row = 0; row < pool_max_size; ++row) + for (row = 0; row < pool_size; ++row) free (pool[row]); free (pool);