Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iq0F9-0003FH-G0 for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Jan 2020 19:46:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iq0F8-0006oq-5J for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Jan 2020 19:46:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iq0F7-0006oj-TS for pgsql-bugs@lists.postgresql.org; Fri, 10 Jan 2020 19:46:49 +0000 Received: from mout.kundenserver.de ([217.72.192.73]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iq0F5-0000V0-8R for pgsql-bugs@lists.postgresql.org; Fri, 10 Jan 2020 19:46:49 +0000 Received: from feivel.credativ.lan ([91.7.174.161]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Md6ZB-1jPtI62bjP-00aBPx; Fri, 10 Jan 2020 20:46:45 +0100 Received: from localhost (localhost [127.0.0.1]) by feivel.credativ.lan (Postfix) with ESMTP id C3D0DE009C; Fri, 10 Jan 2020 20:46:42 +0100 (CET) Message-ID: Subject: Re: BUG #16200: returned data from ESQL/C FETCH is trampling outside assigned memory for CHAR column From: Michael Meskes To: Matthias Apitz Cc: pgsql-bugs@lists.postgresql.org Date: Fri, 10 Jan 2020 20:46:42 +0100 In-Reply-To: <20200110150114.GA3186@c720-r342378> References: <16200-358624daecff6820@postgresql.org> <20200110150114.GA3186@c720-r342378> Organization: PostgreSQL Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-IsYLKiju09CaKODi+1OH" User-Agent: Evolution 3.34.1-2+b1 MIME-Version: 1.0 X-Provags-ID: V03:K1:3ln36yFQYokgDx2s1ke9RhpUXFo2TWExzNewyzV7fLRzFpkImOh O5eBJed6L0NDWcJ7llewpnRXBhx7Y/NcfxSFBb4nuipyKXu/5X4CCYJh1UiegLGoRaaKrqJ tNa8jYNQUytj2CY9C9R7UKnM2RhKo3nO3MBes+lvERLbjzaEI8ZyJyDI82XYSTbeRUyx6qo g2mcC5fhGt4vI1bF4rxpA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:CZdXWBrac+c=:Fg4pu25i22CC8iLn7imHJI EPUdcdkk/Otz+vSeEZJdBH9QjwDSLnyCoUpCkiwlNIXDHa//OqPoxNj32mcwzwHzmOps8hKXF JMhU4uGeeV6d/NfGcc0h2L528xWjvn5AAEBr51SXCJgo35iv+AwMZpfv3YqQoRihQoZs9g4zk KBRISTC/KMhswREjJDqqFmUx6gLwM5kB3jjX1kx58k2f4xDQAIPyp/iMHliypB3CDLrmRHikL 9h/j264Z49Ayu6jRlqYyrDCDUegjxD8wxe5fGpA5E9rd1e4M8mIa5vgq/AmHymJXu0NMSawTa 8RWSGa3a92D6D4nqs2crWpN2dkp3M2/NzDrhmC7+8/8m5l28Q4RATGX6WSGYezyEsZntQI3iB NrAMsM9xOr0edvY1EIbRxTtFqMMPyzRkuox55X6Ry8k2UIBBs9y8k6omxPk56Lg94wmec3dlM LtI7GOPxyNaYtpn6r+Vlu2Tzdv7YsitPASl3TAf7Ba1eH/xTooBQCE1y/Adkk0I29rhAN9f0P wRaR2jluuL6rhKPXcKrSoNAN60yxW4ObfTt2JUU6T8a+E+VSkEH8c6PeZrwF80edkuBuzdm/p D4mOqVIMEQP3njKUWadJXobuUmnxq/5J2iPM6Lr5ZDYiwlE6FEUTFoIgSH+UzfX2crkS2YWjC tQbFMsOGj2RebwzpHQoiYymBKl0gzRhtXF0/cPzoi/0j4fSZQDSj7t9D7KNVbpYne4KGquvk8 p9ikTvtzYURT+PreIEN2YlbRPeO3ASigMORcJYa0PuQxh6vfyDA77uLZx+FwTDTGXvv7VxxFY bkuSj4ieX7t5LSUftsh5yK+yY64shRaZY31mNUu7zmE+qiDul4Xf+cXX7xMmvKFUPLayqMMS5 sBStSgeNvS0r2T1ZBDYZ7HV8aLLABZVUJd6HGeiw0= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=-IsYLKiju09CaKODi+1OH Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > I mean with ESQL/C the general term "Embedded SQL in C". Of course I > do > know that for PostgreSQL the precompiler is named "ecpg". No worries, I was just making sure we do not talk about different things as I have never seen anyone use this abbreviation before. > Neither do I know if there is some written standard, but char strings There is. > IMHO > should be NULL terminated. Our application expects in this example no > more than 16 bytes and that's why we provide a host variable as the > struct member of 17 bytes so the NULL fits into. >=20 > I digged into the sources of the ecpglib and this small fix solved > our problem: > ... Sure, this fixes your use case, but as I said, I'm not sure it's the right thing to do for general use.=20 > > Could you please verify if the indicator is set accordingly?=20 >=20 > If I read the docs here=20 > https://www.postgresql.org/docs/11/ecpg-variables.html#ECPG-INDICATORS > indicator vars are meant to show null values in the table and not the > string truncation. Am I wrong? We do not use indicators at all, but > catch the error condition -213. Sorry, you're right of course. What I meant was the sqlca structure which includes: ... char sqlwarn[8]; /* Element 0: set to 'W' if at least one other is 'W' */ /* 1: if 'W' at least one character string */ /* value was truncated when it was */ /* stored into a host variable. */ ... Michael --=20 Michael Meskes Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) Meskes at (Debian|Postgresql) dot Org Jabber: michael at xmpp dot meskes dot org VfL Borussia! For=C3=A7a Bar=C3=A7a! SF 49ers! Use Debian GNU/Linux, Postgr= eSQL --=-IsYLKiju09CaKODi+1OH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZ/2RWVGI6sRsEOjtNdhXwLvLOyUFAl4Y1KIACgkQNdhXwLvL OyXjOxAAycOcLjK9emUwUGIhU+3CiXaWp2mZE+R1FqbAQh0bgj1fhF7CZzG/ZAmj T/6/8c1D1zaBlgnNuJOrZTT/VynKm6J2OytfAz+VNqzWsulqpY5J4z8ZjkJC0i9B ib+93Jj8r1jp0/5FykFHGcFJj6w042xPVejOJm60BWNjbn0vprQ1Lz+YOdZmEAKK oVc42cSKMT55oSeesddvx1Jw0sEEyDUFL5/WfeR503fXBP/ayCEktV4KjeLJpPAC ciXrbjdqtgikP8K1cA1KBHTFqyE1IdDBrcLu02/hqdXU6YnTXf868RBhx34I6hZX voMOgIsFpxQuyE5ZbCv8V7vNnRV5SO8lXH2kHgr1M6RoKnbJdvv/gcryBuk9rpeX aOgucXhprCgz8aAmx8udeSgNSkXjsa8tC61JSoLJD1eBC6OuEO+gOvVWH2Iw6EnZ 0iYtKhDQAYd3caHGHT4yq2EeDM5XFFpxrnHDJAPOOYlslzBN4BTXg04Cm48p2z2P CWs/R045oWmLuhUy+8B0Ua2rHWLxHjEkv5kR5Ww/vAU2vHM9STwqj/Sw3fFsh+z/ 6R+SKs2K3bnAHxfrv3r79WAId7dJxQ6eUKorjQC0wi24MKPiCDJhGosAdR96S7Va eCQizAqTzadX2gV9dFWN/ryA8ADGWzR/GE2TA4WYskMB4jVqqG8= =8mMx -----END PGP SIGNATURE----- --=-IsYLKiju09CaKODi+1OH--