agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Andrew Dunstan <andrew@dunslane.net>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix incremental JSON parser numeric token reassembly across chun
Date: Fri, 10 Apr 2026 13:32:37 +0000
Message-ID: <E1wBByO-000Iyn-1r@gemulon.postgresql.org> (raw)
Fix incremental JSON parser numeric token reassembly across chunks.
When the incremental JSON parser splits a numeric token across chunk
boundaries, it accumulates continuation characters into the partial
token buffer. The accumulator's switch statement unconditionally
accepted '+', '-', '.', 'e', and 'E' as valid numeric continuations
regardless of position, which violated JSON number grammar
(-? int [frac] [exp]). For example, input "4-" fed in single-byte
chunks would accumulate the '-' into the numeric token, producing an
invalid token that later triggered an assertion failure during
re-lexing.
Fix by tracking parser state (seen_dot, seen_exp, prev character)
across the existing partial token and incoming bytes, so that each
character class is accepted only in its grammatically valid position.
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/2478bd5db0aad3599802636201af7adc170ba280
Modified Files
--------------
src/common/jsonapi.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 55 insertions(+), 6 deletions(-)
view thread (3+ messages) latest in thread
Message-ID: <E1wBByO-000Iyn-1r@gemulon.postgresql.org>
Permalink: ../E1wBByO-000Iyn-1r@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wBByO-000Iyn-1r@gemulon.postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: andrew@dunslane.net, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix incremental JSON parser numeric token reassembly across chun
In-Reply-To: <E1wBByO-000Iyn-1r@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox