ecpg: Fix out-of-bound writes due to processing of invalid bytea data

ECPG assumes that any bytea data it receives from a backend starts with
'\x' as its first two bytes, but a check was missed to enforce that.  A
rogue server sending some garbage bytea data would be able to crash a
client, resulting in a client-side DoS, in the most common cases.

Reported-by: ylwangtju <[email protected]>
Backpatch-through: 14
Security: CVE-2026-16241

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5737110b60afffb90d1178acfaa0fe6881c2f5a9
Author: Michael Paquier <[email protected]>

Modified Files
--------------
src/interfaces/ecpg/ecpglib/data.c                 |  7 ++++++
src/interfaces/ecpg/ecpglib/error.c                |  7 ++++++
src/interfaces/ecpg/include/ecpgerrno.h            |  1 +
src/interfaces/ecpg/test/expected/sql-bytea.c      | 27 ++++++++++++++++++----
src/interfaces/ecpg/test/expected/sql-bytea.stderr | 24 ++++++++++++++++++-
src/interfaces/ecpg/test/sql/bytea.pgc             |  5 ++++
6 files changed, 66 insertions(+), 5 deletions(-)

Reply via email to