pgsql: Fix incremental JSON parser numeric token reassembly across chun - Mailing list pgsql-committers

From Andrew Dunstan
Subject pgsql: Fix incremental JSON parser numeric token reassembly across chun
Date
Msg-id E1wBByO-000Iyn-1r@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: pgsql: Allow autovacuum to use parallel vacuum workers.
Next
From: Andrew Dunstan
Date:
Subject: pgsql: Revert "Add built-in fuzzing harnesses for security testing."