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 1iptdk-0005Je-M0 for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Jan 2020 12:43:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iptdj-00045c-4P for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Jan 2020 12:43:47 +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 1iptdi-00045V-Si for pgsql-bugs@lists.postgresql.org; Fri, 10 Jan 2020 12:43:46 +0000 Received: from mout.kundenserver.de ([212.227.126.133]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iptde-0005T6-TW for pgsql-bugs@lists.postgresql.org; Fri, 10 Jan 2020 12:43:46 +0000 Received: from feivel.credativ.lan ([62.154.226.94]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MqK6l-1jUPF90zRr-00nUg0; Fri, 10 Jan 2020 13:43:40 +0100 Received: from localhost (localhost [127.0.0.1]) by feivel.credativ.lan (Postfix) with ESMTP id 557D4E009C; Fri, 10 Jan 2020 13:43:38 +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: guru@unixarea.de, pgsql-bugs@lists.postgresql.org Date: Fri, 10 Jan 2020 13:43:38 +0100 In-Reply-To: <16200-358624daecff6820@postgresql.org> References: <16200-358624daecff6820@postgresql.org> Organization: PostgreSQL Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.1-2+b1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:X/rt69L1eQqAmZzfdXafYCnL/BTdMEptjfa2jNO3+sAw4kWzFnX Vhf4sKWuOXKFShCSunjsDuZY7ANfMFjIgfa+NyBB80ul/bTIyPEd/px/F6E23L06H37c04c JMGejr8TXfFSdkDHo2/FnBbworYGQr7dWCNQOkyLTLOmrR5ZQIBiJRZzZ8WdCtGb/urHzlV qL0ciobxjTUrchcaAcr9w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:EsMDuUhaKWI=:m55CFcpuYw2N++J4zyF8+z qp82qyd/uYZnqVoPbByQFBr6/knAmJn+ObwKVyAadMsZ1LBHd5aF997zFARmkQQbhMXSuc0Ak O1sFGaPM5pw65/0/LBPn0HF1ixQ0g9nu2LCZXDcZ9XLZadg0IQClAwOWQ3wzt11dihT6ZxAG+ xgBXiVknV3YOe8aWL+N695okdhhJ8HXsWFPj47rQ66erI0DseRaOT/jppxVpXEyEZ1SkLSVyU xmBpKWNnvShjrjBKAY0IdCMq0tQKJe0Rp1XFlsgUaKfolDVGR/e3ElpdKx1PvOsa2wYIByVET Hp8Tdy1ptLuGxH7yduPFhFwCuor3m1BM8gPwEZYh2mt24+/H8naHq0g+/Zcsz2pqdQP7wMy9V tVZiW3JUPDP6AG9wpZOVADHIsy7XAFhcu7Et0joBVH4SdqhuIih2KqlXvfuE3xA6HsboCI9rm n9AFk3XSgLqAgTg3EwsYTRmHXpDyL+Tomv5KDPxpTkIwxbTdstl5/Xa+wyPjyCPWBzUGa/26J aARVcjd/xjb+kfYE+i404J2VQDeuURghrTHc3zqqYoraYaAExegpS7qi+dCZ+XDqOKnniAsb/ Cu551w8UAC/7v+LLxHL4cHywEmvD+2Y7agWw0FlUazU933zKzj8HkMFc3WnyismQLCjdnCux5 CDoM1DS7WVhaPonSWhLEuGn7n6UukhXCwbdQt9BqSV3MUJXiDK8Lum9kr19A8Qj1lD+GLtheG foiMX5YZw/CdTejWH+UxgG57dhOQif/PaHqmspwShq6kdfkSxdONEeN/CPYoY9vKws+vYETzA dfGY5OnxkSi7sMTbZoNuUTp6nDuDhS+wD+xi3IG9o6L/wapSCTdEZYSAyUr/gTgn8EHZ6i74q uyJXJuJI4R+Vtlek1Nxu0v3Aswiy4D9mdrJWZP4JY= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, > We encounter the following problem with ESQL/C: Imagine a table with I assume you mean ECPG, right? ESQL/C would be the Informix compiler. > In the database the CHAR column can contain not only 16 bytes, but 16 > Unicode chars, > which are longer than 16 bytes if one or more of the chars is an UTF- > 8 > multibyte > encoded char. > ... > the DATE. Now the function ECPGdo() places the DATE as "MM.DD.YYYY" > into the area pointed to for the 2nd argument and with this > overwrites > the NULL terminator of the string[17] element. Result is later a > SIGSEGV because the expected string in string[17] is not NULL > terminated anymore :-) > > I would call it a bug, that ECPGdo() puts more than 17 bytes (16 > bytes + > NULL) as return into the place pointed to by the host var pointer > when > the column in the database has more (UTF-8) chars as will fit into > 16+1 byte. Actually I am not sure if this is a bug. I do not remember the standard asking for a null termination at the end of a partial string copy. Please correct me if I am wrong. What it does ask for is setting the indicator accordingly. However, you do not mention any indicator, so I wonder if you checked that one at all. If the string is truncated and the appropriate error action is not taken, that would definitely qualify as a bug. Could you please verify if the indicator is set accordingly? If you have a small test case to reproduce the issue, please send that one. Otherwise I can create my own but probably won't have time before next week. Thanks Michael -- 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ça Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL