postgresql/src
Tom Lane 25a7812cd0 Fix JSON error reporting for many cases of erroneous string values.
The majority of error exit cases in json_lex_string() failed to
set lex->token_terminator, causing problems for the error context
reporting code: it would see token_terminator less than token_start
and do something more or less nuts.  In v14 and up the end result
could be as bad as a crash in report_json_context().  Older
versions accidentally avoided that fate; but all versions produce
error context lines that are far less useful than intended,
because they'd stop at the end of the prior token instead of
continuing to where the actually-bad input is.

To fix, invent some macros that make it less notationally painful
to do the right thing.  Also add documentation about what the
function is actually required to do; and in >= v14, add an assertion
in report_json_context about token_terminator being sufficiently
far advanced.

Per report from Nikolay Shaplov.  Back-patch to all supported
versions.

Discussion: https://postgr.es/m/7332649.x5DLKWyVIX@thinkpad-pgpro
2023-03-13 15:19:00 -04:00
..
backend Fix JSON error reporting for many cases of erroneous string values. 2023-03-13 15:19:00 -04:00
bin Add a DEFAULT option to COPY FROM 2023-03-13 10:01:56 -04:00
common Fix JSON error reporting for many cases of erroneous string values. 2023-03-13 15:19:00 -04:00
fe_utils Revert refactoring of restore command code to shell_restore.c 2023-02-06 08:28:42 +09:00
include Add a DEFAULT option to COPY FROM 2023-03-13 10:01:56 -04:00
interfaces Fix inconsistent error handling for GSS encryption in PQconnectPoll() 2023-03-13 16:36:20 +09:00
makefiles meson: Make auto the default of the ssl option 2023-03-13 07:04:11 +01:00
pl Break up long GETTEXT_FILES lists 2023-03-08 15:05:43 +01:00
port Remove gratuitous references to postmaster program 2023-01-26 10:48:32 +01:00
template Use unnamed POSIX semaphores on Cygwin. 2023-01-06 10:33:28 +13:00
test Fix JSON error reporting for many cases of erroneous string values. 2023-03-13 15:19:00 -04:00
timezone Fix outdated references to guc.c 2023-03-02 13:49:39 +01:00
tools meson: Add target for installing test files & improve install_test_files 2023-03-08 11:12:10 -08:00
tutorial Remove useless casts to (void *) in arguments of some system functions 2023-02-07 06:57:59 +01:00
.gitignore
DEVELOPERS
Makefile Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
Makefile.global.in autoconf: Move export_dynamic determination to configure 2022-12-06 18:55:28 -08:00
Makefile.shlib autoconf: Rely on ar supporting index creation 2022-10-07 11:53:39 -07:00
meson.build Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
nls-global.mk Fix for make unportability 2022-07-13 09:15:01 +02:00