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 1lUoqt-0007vR-5a for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Apr 2021 10:59:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lUoqs-0002mo-0k for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Apr 2021 10:59:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUoqr-0002mG-Qv for pgsql-bugs@lists.postgresql.org; Fri, 09 Apr 2021 10:59:01 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUoqp-00083J-MU for pgsql-bugs@lists.postgresql.org; Fri, 09 Apr 2021 10:59:01 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 6FC311314; Fri, 9 Apr 2021 06:58:56 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 09 Apr 2021 06:58:56 -0400 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=fm1; bh=RAKDV2q7lsUcBph/O5Y8f2O7ndU bPOO8T/CQxTRO518=; b=aXWkJyDlovRJ1gZfghgIqx7N17LoMG8fJUepVygavRd MboY3xJ1YbGuXhu/cK1KYEUgUZQzMP4KvsnaE9p/4X2p09k2OTiNn8vqWtV7bdnW L2YrsyfmPxdn20Nvykb1LmQ7FJHHN0b/1oqTJ0eQ3hJsdiATL5Rd5dVJEyYDkI7O 5PkGcRP6wETOL0CAf5OktRsDXu1/cdbIFFWF0LJ3FdRR5hQmGBinv8hKolmRKGjK kf2hBGzNTsnCY4FUpOM5HXe6ovVcD+YQTmCGDt5X6EUIunM1Uuoxjxkx4xDG0rXs UepbNCPXTkvu7YeSg8nIN7nabRkIwAxdJdJEBwZrdCQ== 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=fm2; bh=RAKDV2 q7lsUcBph/O5Y8f2O7ndUbPOO8T/CQxTRO518=; b=KwTjA8Zu/mUlyuApW59+F0 lgds8r2a/t0fk2weEIfumtlWz64L1xPZJ9VUDHyUShKbXc8T8iEQlME27rY3RLuO CXjrtBFelre98f1/0Waf02Te69dpmYrqw0OUhHZoKAJqHRT7rNF0/DU7BRmgEmMC WFb0QdatZcX4y/cA8vQstK8aKjMd+UxWbS7KiIff4gdi5XDRk8+R+3yMLkW8dbtw 3EyCp1UZCUml1v/ifVgephqq4f3CIQjI16xgDrik0M+srfQuZTbK8zRTFG6hpFgk GbOQw0oPWET1yXwrAsZ2zTq3WJdBXqUIlVMhIRWUW1DrsmMHluP2VQKaINZmtcrg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudekuddgfeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhf fvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhu ihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrh hnpedvgeduuefhtdeuleettdevjeehheeiveeuieegleetgeeljeelieeuieehgeevhfen ucfkphepudduuddruddtvddrudektddrudekheenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 4F11D1080054; Fri, 9 Apr 2021 06:58:54 -0400 (EDT) Date: Fri, 9 Apr 2021 19:58:51 +0900 From: Michael Paquier To: Julien Rouhaud Cc: t.larionov@postgrespro.ru, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16953: OOB access while converting "interval" to char Message-ID: References: <16953-f255a18f8c51f1d5@postgresql.org> <20210407120856.3rjxxnnzzxn74vyv@nol> <20210408110403.wr3d552xilqsx4us@nol> <20210409104246.vkeef6rbyevq46f3@nol> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7lz4ldiEuo9//NqT" Content-Disposition: inline In-Reply-To: <20210409104246.vkeef6rbyevq46f3@nol> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --7lz4ldiEuo9//NqT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Apr 09, 2021 at 06:42:46PM +0800, Julien Rouhaud wrote: > I'm not sure what you mean by that. We receive a pg_tm struct which can't > contain more than 12 in tm_mon right? And actually for intervals it will > reduce "12 months" to "1 year 0 month", so to_char previously didn't report > anything for 12 months either. I did not take the time to look in details, but for reference I just imagined that a formula like this one would give pretty much the position in rm_months_upper: M_PER_Y - ((tm_mon % M_PER_Y) + M_PER_Y) % M_PER_Y > Hearing no other opinion I went with -1 -> december and so on in attached v2. > I also fixed the "[-]12 months" case and updated the regression tests. Given > the extra code needed to deduce the correct array position I factorized DCH_RM > and DCH_rm. Yep. The regression tests show what I would expect. I'll check in details later. -- Michael --7lz4ldiEuo9//NqT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmBwM2sACgkQnvQgOdby QH2qYg/8C6js/KKpn9NeZtCBpuAtTpRU7WQ4myX3czsvXpzF5mRHWJfKwWUjvcoz YqHI6yYFX8SXJ9IL7nJMhxeVTUHzBKgXtR4Sb0tR4fv9i4SnTj12GKAZwKbcmCbl +LC30mcuhgfMey/pja46OzugsQlUYWneD3OERIYelEpoDaCflSmt3Hwn1Kr6BTz9 NBstBvcpNabtRnwI36GpVmN/Dok4oTBmJ5uZzYRdG94VzxFCwT8ygRbTotr+G06m aawZCu7ZHmf1mxthj/rSEjTP5hcq6rCyI6wHy8/7thJcwdHOmADZUsC2gcj0kmsn unq+N6HzewxSpd+pwpNKF2FSgTmDRHzxqvk1ENfXz0vK8TctCbSXiR/dPHhPre7f A5w43RDBqG/nveqC315TjJPaIdAXUNY3yJK2wTdulkSohjWYUZrrrCWQ9uDFzRni b0b2tFZFP8a9uYoK33nu1Ay11oRJLhkYobg4IrO47zKZgWOFdfcLNgGXZ02oHejS /1mapnviuhPJnX92CUFWSgDhTf0qFOtEqMhzhSy/MaPM/TL2Nm7lh7xbVUedORFB ndScYINO4TkOKBI1mNicMNsU8w6OdrFqjt7eLyfZbeqEvEhD/xCpzPfNjao03IYG GCryhEmJhYOTJ6V5xmXsO3l0QETru+/1l9Of/TXD9VWw7P6nEfM= =as1Z -----END PGP SIGNATURE----- --7lz4ldiEuo9//NqT--