ecpg: Fix zero-termination of string generated by intoasc()
Michael Paquier <michael@paquier.xyz>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/interfaces/ecpg/compatlib/informix.c | modified | +1 −1 |
| src/interfaces/ecpg/test/compat_informix/.gitignore | modified | +2 −0 |
| src/interfaces/ecpg/test/compat_informix/intoasc.pgc | added | +21 −0 |
| src/interfaces/ecpg/test/compat_informix/Makefile | modified | +2 −1 |
| src/interfaces/ecpg/test/ecpg_schedule | modified | +1 −0 |
| src/interfaces/ecpg/test/expected/compat_informix-intoasc.c | added | +40 −0 |
| src/interfaces/ecpg/test/expected/compat_informix-intoasc.stderr | added | +0 −0 |
| src/interfaces/ecpg/test/expected/compat_informix-intoasc.stdout | added | +2 −0 |
Discussion
- Returning non-terminated string in ECPG Informix-compatible function 7 messages · 2024-01-29 → 2024-02-19