| From: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: IS JSON/JSON(): Protect against expressions uncoercible to text |
| Date: | 2026-06-11 14:19:48 |
| Message-ID: | E1wXgG4-0020zu-0e@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
IS JSON/JSON(): Protect against expressions uncoercible to text
transformJsonParseArg() was not careful enough on generation of
transformed expressions when starting from expressions that are not
coercible to text but are in the string type category: it failed to
verify that coerce_to_target_type() succeeds, and returned a NULL
pointer. This leads to a later NULL dereference and crash at executor
time.
This escaped noticed because it cannot happen for built-in types, all of
which have casts to text. Only user-created types are potentially
problematic.
Fix by raising an error when a cast to text doesn't exist.
This mistake came in with commit 6ee30209a6f1.
Author: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Reported-by: Chi Zhang <798604270(at)qq(dot)com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
Backpatch-through: 16
Discussion: https://postgr.es/m/19491-7aafc221ec63f288@postgresql.org
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/35d9a6263407563f9948a38fced5419deab297a2
Modified Files
--------------
src/backend/nodes/makefuncs.c | 2 ++
src/backend/parser/parse_expr.c | 10 +++++++++
src/test/regress/expected/sqljson.out | 38 +++++++++++++++++++++++++++++++++++
src/test/regress/sql/sqljson.sql | 22 ++++++++++++++++++++
4 files changed, 72 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Álvaro Herrera | 2026-06-11 16:34:45 | pgsql: Fix translatable string construction |
| Previous Message | Dean Rasheed | 2026-06-11 11:10:54 | pgsql: Fix parsing of parenthesised OLD/NEW in RETURNING list. |