Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ml0Ch-0006NE-Tn for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Nov 2021 02:52:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ml0Cg-0002yq-IP for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Nov 2021 02:52:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ml0Cf-0002yf-NH for pgsql-bugs@lists.postgresql.org; Thu, 11 Nov 2021 02:52:42 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ml0Cd-0002vV-1D for pgsql-bugs@lists.postgresql.org; Thu, 11 Nov 2021 02:52:40 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 960683200C17; Wed, 10 Nov 2021 21:52:37 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 10 Nov 2021 21:52:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=lUVrv8NlhrEmF0kirbGanVXCS7L zXBeInfi5/CzS54A=; b=q1coIWqnn3+X1RagKLXjC1WJaRvrjJVYUU6kbnMvstW 7Ja2eE/xQ/ZxBnrOaQOP9uMXfNC0skJenYcTLh6KhOet5IViwzlbvkq4/vcfmW8S yuDdioMONJM+zsO/ogzRmqkXY2C3zFzGyDX2o+84j6PJVAfHQOuL0xH9EIiowHh6 fVdj3Xovvz9y8UtIDV8eR0lg2jgJmwR7XBf00J56+vkAMKDtAI2Bngjh6auTQTR/ GNKa5o6+32gk7SA1qKQtSNWg2NTBPAM+8rdz8txWeG8Yv3vy5mVhsRBGa1yNaKR0 p9uGZR5nGwAvgsuoqSyLj0nl7la1adYjjg8lgEpFUxg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=lUVrv8 NlhrEmF0kirbGanVXCS7LzXBeInfi5/CzS54A=; b=Pm5qoXFVTqAqVwegysBvzW MY5X3v3mqojNZ7TNX67CcUqHwh8MkOFzQDA1YMxUwtHGTnkw7w9i/NEWWOlK+yBL UK6DEzGFckG+Dhg2z84cP+BENT3jpx+/S5kxYnylTH58UQDjXtpFzZt1OQF+Uv+D NxILEcugkj7jHPwNE6YuksH32mhyvkDp0efshHXiZvugH+acr/zFFghxuOPW8BnR MZMsJXSb86mqpaGt/OmcdHOfxeP0J0p+eZ9oMUzZyxRGzmKwcYsTV7UaoVg6N6z2 LD8yrY6cCCDMdVK5qvFdkVsvZUd5Y5StttbN4BiJyDgPREApx1w22P3ZfPU5SAew == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrvddtgdegkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvf fukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhi vghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnh epvdegudeuhfdtueeltedtveejheehieevueeigeelteegleejleeiueeiheegvefhnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrg gvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 10 Nov 2021 21:52:34 -0500 (EST) Date: Thu, 11 Nov 2021 11:52:27 +0900 From: Michael Paquier To: Kyotaro Horiguchi Cc: a.kozhemyakin@postgrespro.ru, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17280: global-buffer-overflow on select from pg_stat_slru Message-ID: References: <17280-37da556e86032070@postgresql.org> <20211111.103923.2138998724021170559.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="rl8kW6/5mVYI+il7" Content-Disposition: inline In-Reply-To: <20211111.103923.2138998724021170559.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --rl8kW6/5mVYI+il7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 11, 2021 at 10:39:23AM +0900, Kyotaro Horiguchi wrote: > The loop is designed not to directly rely on SRLU_NUM_ELEMENTS so if > we honor that design, we would take the first or the third way. The > first way is smallest but I prefer the third way as it is > straightforward as such kind of loops. The attached is that for the > master. >=20 > The code was introduced at 13 and the attached applies to the versions > back to 13. Or it would be easier for the reader to assign stat after checking for the result of pgstat_slru_name(), no? I am not much a fan of this code style that uses a counter, FWIW, but at the same time SLRU_NUM_ELEMENTS is local to pgstat.c, so.. -- Michael --rl8kW6/5mVYI+il7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmGMhWoACgkQnvQgOdby QH3JCxAAn7VE8p1jcdXfAlN10UcIySn6dcF9MSlb6MbsCp6D2SLevfafZ+OnXDUx A6XGaDGwFZdqd9jv4ixyvJQJhY7rWVGkztuWwgpBbX0rZqDPaLC0bOHERaSgNzPW SpVbup2dlOh1q+p0tDolwi3JlFUjNarbsGQCWoSFzU5norTdKHtf95OyUBYrAviq UDz5339siuWWHoKhvR+Q0LyVz9iFlYafqs73sjIwJfVlVHAUf44JSU17gN/x1CHI B7kY5tyU9Eqj7OGi+EUY+RCWjGEzNwTTg0WFNUfZSJyWk2fbl55zoOUw7+Uy6ENX QXgwAq/M/RhCA5oxrIqYiw1DFXLCfQYQ+lb9jPGI0TEjPcU8sqmKzWZ95GpCHXb1 ENoc07jXbk1iIwWhB2I4J3Nch+O7qB1N/eWcjIzkqs+zdrkPllGETrCAA+kgI/qq Aj2X9xLpal23fI4DI7vw+jX6c2W7amL8Lw6UgrOGDVhQYHMDYgcjrNloOi3FCs0u MXv5bsegwml1QFeFJBM10KSmcMz7ST+tbFzJ2UI9RDo3RSNghp2pDZTeYS95b89t GyXBD2Mjh9hETD93VKSXVMIxzHvNdy4c48hnc95VEHkU6pI0B8MkVoT762nrztMv g7gVsZ8gRCQxYzounCw4ug9fCQ6fCoaJinJl1FBnG9VRmFp8yKU= =apTt -----END PGP SIGNATURE----- --rl8kW6/5mVYI+il7--