Re: BUG #16200: ESQL/C FETCH of CHAR data delivers to much data for UTF-8

Matthias Apitz <[email protected]> Fri, 10 Jan 2020 12:55:39 +0100
Newsgroups gmane.comp.db.postgresql.bugs
Message-ID <[email protected]>
The following change solves our problem:

postgresql-11.4/src/interfaces/ecpg> diff ecpglib/data.c ecpglib/data.c.orig          
527,531c527
<                                                       /* [email protected]: strncpy() only varcharsize-1 */
<                                                       strncpy(str, pval, varcharsize-1);
<                                                       /* [email protected]: 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, ✉ [email protected], http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
May, 9: Спаси́бо освободители! Thank you very much, Russian liberators!