public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michael Paquier <[email protected]>
To: [email protected]
Subject: pgsql: ecpg: Fix zero-termination of string generated by intoasc()
Date: Mon, 19 Feb 2024 02:39:20 +0000
Message-ID: <[email protected]> (raw)

ecpg: Fix zero-termination of string generated by intoasc()

intoasc(), a wrapper for PGTYPESinterval_to_asc that converts an
interval to its textual representation, used a plain memcpy() when
copying its result.  This could miss a zero-termination in the result
string, leading to an incorrect result.

The routines in informix.c do not provide the length of their result
buffer, which would allow a replacement of strcpy() to safer strlcpy()
calls, but this requires an ABI breakage and that cannot happen in
back-branches.

Author: Oleg Tselebrovskiy
Reviewed-by: Ashutosh Bapat
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 12

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a05bb9addb3770d07cc90ebfd5e2486e63647bce

Modified Files
--------------
src/interfaces/ecpg/compatlib/informix.c           |  2 +-
.../ecpg/test/compat_informix/.gitignore           |  2 ++
src/interfaces/ecpg/test/compat_informix/Makefile  |  3 +-
.../ecpg/test/compat_informix/intoasc.pgc          | 21 ++++++++++++
src/interfaces/ecpg/test/ecpg_schedule             |  1 +
.../ecpg/test/expected/compat_informix-intoasc.c   | 40 ++++++++++++++++++++++
.../test/expected/compat_informix-intoasc.stderr   |  0
.../test/expected/compat_informix-intoasc.stdout   |  2 ++
8 files changed, 69 insertions(+), 2 deletions(-)



view thread (6+ messages)  latest in thread

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: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: ecpg: Fix zero-termination of string generated by intoasc()
  In-Reply-To: <[email protected]>

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

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