pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix JSON error reporting for many cases of erroneous string valu 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix JSON error reporting for many cases of erroneous string valu @ 2023-03-13 19:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-03-13 19:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/52e9a781656edefb10e8371d46a1a6d62c1bbb11 Modified Files -------------- src/common/jsonapi.c | 77 ++++++++++++++++----------- src/test/regress/expected/json_encoding.out | 24 ++++----- src/test/regress/expected/json_encoding_1.out | 24 ++++----- 3 files changed, 71 insertions(+), 54 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix JSON error reporting for many cases of erroneous string valu @ 2023-03-13 19:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-03-13 19:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0ee9d685dd80910a269eb44036dc59df511c6d88 Modified Files -------------- src/backend/utils/adt/jsonfuncs.c | 1 + src/common/jsonapi.c | 77 ++++++++++++++++----------- src/test/regress/expected/json_encoding.out | 24 ++++----- src/test/regress/expected/json_encoding_1.out | 24 ++++----- 4 files changed, 72 insertions(+), 54 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix JSON error reporting for many cases of erroneous string valu @ 2023-03-13 19:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-03-13 19:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/74a1a36d755bf5a5c656d78ef7f1df1cfeeeeb20 Modified Files -------------- src/backend/utils/adt/jsonfuncs.c | 1 + src/common/jsonapi.c | 77 ++++++++++++++++----------- src/test/regress/expected/json_encoding.out | 24 ++++----- src/test/regress/expected/json_encoding_1.out | 24 ++++----- 4 files changed, 72 insertions(+), 54 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix JSON error reporting for many cases of erroneous string valu @ 2023-03-13 19:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-03-13 19:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c25a929a6c8869a148b3ee064eb03ab1d3cb127d Modified Files -------------- src/backend/utils/adt/json.c | 29 +++++++++++++++++++-- src/test/regress/expected/json_encoding.out | 24 +++++++++--------- src/test/regress/expected/json_encoding_1.out | 36 +++++++++++++-------------- 3 files changed, 57 insertions(+), 32 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix JSON error reporting for many cases of erroneous string valu @ 2023-03-13 19:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-03-13 19:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/234941a3bbf32266e9e2d3d9bc7648aec850d8c4 Modified Files -------------- src/backend/utils/adt/json.c | 29 +++++++++++++++++++-- src/test/regress/expected/json_encoding.out | 24 +++++++++--------- src/test/regress/expected/json_encoding_1.out | 36 +++++++++++++-------------- 3 files changed, 57 insertions(+), 32 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix JSON error reporting for many cases of erroneous string valu @ 2023-03-13 19:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-03-13 19:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/25a7812cd0867043ec0a045c41e6bd3981d69bc4 Modified Files -------------- src/backend/utils/adt/jsonfuncs.c | 1 + src/common/jsonapi.c | 76 +++++++++++++++++---------- src/test/regress/expected/json_encoding.out | 24 ++++----- src/test/regress/expected/json_encoding_1.out | 36 ++++++------- 4 files changed, 78 insertions(+), 59 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2023-03-13 19:19 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-03-13 19:19 pgsql: Fix JSON error reporting for many cases of erroneous string valu Tom Lane <tgl@sss.pgh.pa.us> 2023-03-13 19:19 pgsql: Fix JSON error reporting for many cases of erroneous string valu Tom Lane <tgl@sss.pgh.pa.us> 2023-03-13 19:19 pgsql: Fix JSON error reporting for many cases of erroneous string valu Tom Lane <tgl@sss.pgh.pa.us> 2023-03-13 19:19 pgsql: Fix JSON error reporting for many cases of erroneous string valu Tom Lane <tgl@sss.pgh.pa.us> 2023-03-13 19:19 pgsql: Fix JSON error reporting for many cases of erroneous string valu Tom Lane <tgl@sss.pgh.pa.us> 2023-03-13 19:19 pgsql: Fix JSON error reporting for many cases of erroneous string valu Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox