]> git.ipfire.org Git - thirdparty/postgresql.git/commit
ecpg: Fix zero-termination of string generated by intoasc()
authorMichael Paquier <michael@paquier.xyz>
Mon, 19 Feb 2024 02:38:47 +0000 (11:38 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 19 Feb 2024 02:38:47 +0000 (11:38 +0900)
commitb5cb6022bbf0a748220a1086aa398214dfca7c6d
tree5e7c22b204bb5507dcaafe9062b8eeb897906d59
parent1d577f2eaa88b1d4caab3e859a01d25ecd9f81c5
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/bf47888585149f83b276861a1662f7e4@postgrespro.ru
Backpatch-through: 12
src/interfaces/ecpg/compatlib/informix.c
src/interfaces/ecpg/test/compat_informix/.gitignore
src/interfaces/ecpg/test/compat_informix/Makefile
src/interfaces/ecpg/test/compat_informix/intoasc.pgc [new file with mode: 0644]
src/interfaces/ecpg/test/ecpg_schedule
src/interfaces/ecpg/test/expected/compat_informix-intoasc.c [new file with mode: 0644]
src/interfaces/ecpg/test/expected/compat_informix-intoasc.stderr [new file with mode: 0644]
src/interfaces/ecpg/test/expected/compat_informix-intoasc.stdout [new file with mode: 0644]