pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: ecpg: Fix handling of strings in ORACLE compat code with SQLDA
Date: Tue, 18 Apr 2023 02:21:31 +0000
Message-ID: <E1poayI-003cfb-I8@gemulon.postgresql.org> (raw)

ecpg: Fix handling of strings in ORACLE compat code with SQLDA

When compiled with -C ORACLE, ecpg_get_data() had a one-off issue where
it would incorrectly store the null terminator byte to str[-1] when
varcharsize is 0, which is something that can happen when using SQLDA.
This would eat 1 byte from the previous field stored, corrupting the
results generated.

All the callers of ecpg_get_data() estimate and allocate enough storage
for the data received, and the fix of this commit relies on this
assumption.  Note that this maps to the case where no padding or
truncation is required.

This issue has been introduced by 3b7ab43 with the Oracle compatibility
option, so backpatch down to v11.

Author: Kyotaro Horiguchi
Discussion: https://postgr.es/m/20230410.173500.440060475837236886.horikyota.ntt@gmail.com
Backpatch-through: 11

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/02f0764546a9ce7f3d843e049bdfa790afa1cf4a

Modified Files
--------------
src/interfaces/ecpg/ecpglib/data.c                 |  19 +-
.../ecpg/test/compat_oracle/char_array.pgc         |  31 ++-
.../ecpg/test/expected/compat_oracle-char_array.c  | 216 +++++++++++++++------
.../test/expected/compat_oracle-char_array.stderr  | 166 +++++++++-------
.../test/expected/compat_oracle-char_array.stdout  |   5 +
5 files changed, 310 insertions(+), 127 deletions(-)



view thread (6+ messages)

Message-ID: <E1poayI-003cfb-I8@gemulon.postgresql.org>
Permalink:  ../E1poayI-003cfb-I8@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1poayI-003cfb-I8@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: ecpg: Fix handling of strings in ORACLE compat code with SQLDA
  In-Reply-To: <E1poayI-003cfb-I8@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox