Re: Returning non-terminated string in ECPG Informix-compatible function
Oleg Tselebrovskiy <o.tselebrovskiy@postgrespro.ru>
From: Oleg Tselebrovskiy <o.tselebrovskiy@postgrespro.ru>
To: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2024-02-15T05:15:40Z
Lists: pgsql-hackers
Attachments
- ecpg_bugfixes.patch (text/x-diff) patch
Greetings again. I was looking through more static analyzer output and found another problem. In ecpg/pgtypeslib/dt_common.c there are 4 calls of pgtypes_alloc. This function uses calloc and returns NULL if OOM, but we don't check its return value and immediately pass it to strcpy, which could lead to segfault. I suggest adding a check for a return value since all other calls of pgtypes_alloc are checked for NULL. A proposed patch (with previous and current changes) is attached Oleg Tselebrovskiy, Postgres Pro
Commits
-
ecpg: Fix zero-termination of string generated by intoasc()
- 771240f972ee 12.19 landed
- c031ce97b561 13.15 landed
- a05bb9addb37 14.12 landed
- b5cb6022bbf0 15.7 landed
- 88e03d055d18 16.3 landed
- e77a1c58e338 17.0 landed
-
ecpg: Fix error handling on OOMs when parsing timestamps
- 0a9118ccc0eb 17.0 landed