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 1ipstK-0003Ky-V3 for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Jan 2020 11:55: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 1ipstJ-0004v8-KO for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Jan 2020 11:55:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ipstJ-0004v1-8y for pgsql-bugs@lists.postgresql.org; Fri, 10 Jan 2020 11:55:49 +0000 Received: from smh-06.1blu.de ([178.254.0.206]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ipstG-0001Ci-Hd for pgsql-bugs@lists.postgresql.org; Fri, 10 Jan 2020 11:55:48 +0000 Received: from [172.16.29.5] (helo=sh4-5.1blu.de) by smh-06.1blu.de with esmtp (Exim 4.86_2) (envelope-from ) id 1ipst9-0008Be-O2; Fri, 10 Jan 2020 12:55:40 +0100 Received: from ftp51246-2575596 by sh4-5.1blu.de with local (Exim 4.86_2) (envelope-from ) id 1ipst9-001nau-Ml; Fri, 10 Jan 2020 12:55:39 +0100 Date: Fri, 10 Jan 2020 12:55:39 +0100 From: Matthias Apitz To: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16200: ESQL/C FETCH of CHAR data delivers to much data for UTF-8 Message-ID: <20200110115539.GA426730@sh4-5.1blu.de> Reply-To: Matthias Apitz MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Operating-System: FreeBSD 12.0-CURRENT r314251 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk The following change solves our problem: postgresql-11.4/src/interfaces/ecpg> diff ecpglib/data.c ecpglib/data.c.orig 527,531c527 < /* guru@unixarea.de: strncpy() only varcharsize-1 */ < strncpy(str, pval, varcharsize-1); < /* guru@unixarea.de: and terminate the string */ < str[varcharsize - 1] = '\0'; < ecpg_log("DEBUG ESQL/C: result [%s] len %d\n", str, strlen(str)); --- > strncpy(str, pval, varcharsize); -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub May, 9: Спаси́бо освободители! Thank you very much, Russian liberators!