agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Save/restore more lexer state when skipping text due to \if. 5+ messages / 1 participants [nested] [flat]
* pgsql: Save/restore more lexer state when skipping text due to \if. @ 2026-08-10 13:41 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 5+ messages in thread From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore more lexer state when skipping text due to \if. When we implemented \if ... \endif in psql, we arranged to save/restore the lexer's parenthesis depth counter across any chunk of input that we're ignoring. At the time, that was sufficient, because no other part of PsqlScanState could need to be restored to its prior value. However, commit e717a9a18 and follow-ons added more state fields that ought to be restored to their prior values. A problem would only be observed if someone tries to \if out a portion of a CREATE FUNCTION/PROCEDURE command that is relevant to BEGIN/END matching, which seems like a pretty unusual usage, so the lack of field reports isn't surprising. Nonetheless it's a bug. To fix, replace the simple counter field in ConditionalStack entries with a pointer to a struct defined by psqlscan_int.h. (In the back branches, keep the old field and associated functions to minimize the risk of API/ABI breakage, even though it seems unlikely that any third-party code is using this. Making the new struct private to psqlscan-related code should prevent API/ABI issues for future additions of this type.) In itself this is only a minor bug fix, but it's prerequisite infrastructure for the fix for CVE-2026-6464, which will add another such field. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Noah Misch <noah@leadboat.com> Backpatch-through: 14 Security: CVE-2026-6464 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/cf754f7414ba6159733ee9cdffde90a3cee3c32c Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/bin/psql/command.c | 16 +++++++-------- src/bin/psql/psqlscanslash.h | 5 +++-- src/bin/psql/psqlscanslash.l | 40 +++++++++++++++++++++++++++++-------- src/fe_utils/conditional.c | 28 ++++++++++++++++---------- src/include/fe_utils/conditional.h | 16 +++++++-------- src/include/fe_utils/psqlscan.h | 3 +++ src/include/fe_utils/psqlscan_int.h | 20 +++++++++++++++++++ src/test/regress/expected/psql.out | 16 +++++++++++++++ src/test/regress/sql/psql.sql | 11 ++++++++++ src/tools/pgindent/typedefs.list | 1 + 10 files changed, 119 insertions(+), 37 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Save/restore more lexer state when skipping text due to \if. @ 2026-08-10 13:41 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 5+ messages in thread From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore more lexer state when skipping text due to \if. When we implemented \if ... \endif in psql, we arranged to save/restore the lexer's parenthesis depth counter across any chunk of input that we're ignoring. At the time, that was sufficient, because no other part of PsqlScanState could need to be restored to its prior value. However, commit e717a9a18 and follow-ons added more state fields that ought to be restored to their prior values. A problem would only be observed if someone tries to \if out a portion of a CREATE FUNCTION/PROCEDURE command that is relevant to BEGIN/END matching, which seems like a pretty unusual usage, so the lack of field reports isn't surprising. Nonetheless it's a bug. To fix, replace the simple counter field in ConditionalStack entries with a pointer to a struct defined by psqlscan_int.h. (In the back branches, keep the old field and associated functions to minimize the risk of API/ABI breakage, even though it seems unlikely that any third-party code is using this. Making the new struct private to psqlscan-related code should prevent API/ABI issues for future additions of this type.) In itself this is only a minor bug fix, but it's prerequisite infrastructure for the fix for CVE-2026-6464, which will add another such field. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Noah Misch <noah@leadboat.com> Backpatch-through: 14 Security: CVE-2026-6464 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8cf01e213ccc33e22e87b49e2711e4a83b4f01e0 Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/bin/psql/command.c | 16 +++++++-------- src/bin/psql/psqlscanslash.h | 5 +++-- src/bin/psql/psqlscanslash.l | 40 +++++++++++++++++++++++++++++-------- src/fe_utils/conditional.c | 28 ++++++++++++++++---------- src/include/fe_utils/conditional.h | 16 +++++++-------- src/include/fe_utils/psqlscan.h | 3 +++ src/include/fe_utils/psqlscan_int.h | 20 +++++++++++++++++++ src/test/regress/expected/psql.out | 16 +++++++++++++++ src/test/regress/sql/psql.sql | 11 ++++++++++ src/tools/pgindent/typedefs.list | 1 + 10 files changed, 119 insertions(+), 37 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Save/restore more lexer state when skipping text due to \if. @ 2026-08-10 13:41 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 5+ messages in thread From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore more lexer state when skipping text due to \if. When we implemented \if ... \endif in psql, we arranged to save/restore the lexer's parenthesis depth counter across any chunk of input that we're ignoring. At the time, that was sufficient, because no other part of PsqlScanState could need to be restored to its prior value. However, commit e717a9a18 and follow-ons added more state fields that ought to be restored to their prior values. A problem would only be observed if someone tries to \if out a portion of a CREATE FUNCTION/PROCEDURE command that is relevant to BEGIN/END matching, which seems like a pretty unusual usage, so the lack of field reports isn't surprising. Nonetheless it's a bug. To fix, replace the simple counter field in ConditionalStack entries with a pointer to a struct defined by psqlscan_int.h. (In the back branches, keep the old field and associated functions to minimize the risk of API/ABI breakage, even though it seems unlikely that any third-party code is using this. Making the new struct private to psqlscan-related code should prevent API/ABI issues for future additions of this type.) In itself this is only a minor bug fix, but it's prerequisite infrastructure for the fix for CVE-2026-6464, which will add another such field. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Noah Misch <noah@leadboat.com> Backpatch-through: 14 Security: CVE-2026-6464 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/900894d35ca72bfba853447ca986bdced4ad993b Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/bin/psql/command.c | 16 +++++++--------- src/bin/psql/psqlscanslash.h | 5 +++++ src/bin/psql/psqlscanslash.l | 38 +++++++++++++++++++++++++++++++++++++ src/fe_utils/conditional.c | 34 +++++++++++++++++++++++++++++++++ src/include/fe_utils/conditional.h | 17 +++++++++++------ src/include/fe_utils/psqlscan.h | 3 +++ src/include/fe_utils/psqlscan_int.h | 17 +++++++++++++++++ src/test/regress/expected/psql.out | 16 ++++++++++++++++ src/test/regress/sql/psql.sql | 11 +++++++++++ src/tools/pgindent/typedefs.list | 1 + 10 files changed, 143 insertions(+), 15 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Save/restore more lexer state when skipping text due to \if. @ 2026-08-10 13:41 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 5+ messages in thread From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore more lexer state when skipping text due to \if. When we implemented \if ... \endif in psql, we arranged to save/restore the lexer's parenthesis depth counter across any chunk of input that we're ignoring. At the time, that was sufficient, because no other part of PsqlScanState could need to be restored to its prior value. However, commit e717a9a18 and follow-ons added more state fields that ought to be restored to their prior values. A problem would only be observed if someone tries to \if out a portion of a CREATE FUNCTION/PROCEDURE command that is relevant to BEGIN/END matching, which seems like a pretty unusual usage, so the lack of field reports isn't surprising. Nonetheless it's a bug. To fix, replace the simple counter field in ConditionalStack entries with a pointer to a struct defined by psqlscan_int.h. (In the back branches, keep the old field and associated functions to minimize the risk of API/ABI breakage, even though it seems unlikely that any third-party code is using this. Making the new struct private to psqlscan-related code should prevent API/ABI issues for future additions of this type.) In itself this is only a minor bug fix, but it's prerequisite infrastructure for the fix for CVE-2026-6464, which will add another such field. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Noah Misch <noah@leadboat.com> Backpatch-through: 14 Security: CVE-2026-6464 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/dca6627de0f3b5a5798529b4ad5012a9e9b55f49 Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/bin/psql/command.c | 16 +++++++--------- src/bin/psql/psqlscanslash.h | 5 +++++ src/bin/psql/psqlscanslash.l | 38 +++++++++++++++++++++++++++++++++++++ src/fe_utils/conditional.c | 34 +++++++++++++++++++++++++++++++++ src/include/fe_utils/conditional.h | 17 +++++++++++------ src/include/fe_utils/psqlscan.h | 3 +++ src/include/fe_utils/psqlscan_int.h | 17 +++++++++++++++++ src/test/regress/expected/psql.out | 16 ++++++++++++++++ src/test/regress/sql/psql.sql | 11 +++++++++++ src/tools/pgindent/typedefs.list | 1 + 10 files changed, 143 insertions(+), 15 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Save/restore more lexer state when skipping text due to \if. @ 2026-08-10 13:41 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 5+ messages in thread From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore more lexer state when skipping text due to \if. When we implemented \if ... \endif in psql, we arranged to save/restore the lexer's parenthesis depth counter across any chunk of input that we're ignoring. At the time, that was sufficient, because no other part of PsqlScanState could need to be restored to its prior value. However, commit e717a9a18 and follow-ons added more state fields that ought to be restored to their prior values. A problem would only be observed if someone tries to \if out a portion of a CREATE FUNCTION/PROCEDURE command that is relevant to BEGIN/END matching, which seems like a pretty unusual usage, so the lack of field reports isn't surprising. Nonetheless it's a bug. To fix, replace the simple counter field in ConditionalStack entries with a pointer to a struct defined by psqlscan_int.h. (In the back branches, keep the old field and associated functions to minimize the risk of API/ABI breakage, even though it seems unlikely that any third-party code is using this. Making the new struct private to psqlscan-related code should prevent API/ABI issues for future additions of this type.) In itself this is only a minor bug fix, but it's prerequisite infrastructure for the fix for CVE-2026-6464, which will add another such field. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Noah Misch <noah@leadboat.com> Backpatch-through: 14 Security: CVE-2026-6464 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/db96e87f93016930b9bc2cf5ec46188f27837e3f Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/bin/psql/command.c | 16 +++++++--------- src/bin/psql/psqlscanslash.h | 5 +++++ src/bin/psql/psqlscanslash.l | 38 +++++++++++++++++++++++++++++++++++++ src/fe_utils/conditional.c | 34 +++++++++++++++++++++++++++++++++ src/include/fe_utils/conditional.h | 17 +++++++++++------ src/include/fe_utils/psqlscan.h | 3 +++ src/include/fe_utils/psqlscan_int.h | 17 +++++++++++++++++ src/test/regress/expected/psql.out | 16 ++++++++++++++++ src/test/regress/sql/psql.sql | 11 +++++++++++ src/tools/pgindent/typedefs.list | 1 + 10 files changed, 143 insertions(+), 15 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2026-08-10 13:41 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-08-10 13:41 pgsql: Save/restore more lexer state when skipping text due to \if. Noah Misch <noah@leadboat.com> 2026-08-10 13:41 pgsql: Save/restore more lexer state when skipping text due to \if. Noah Misch <noah@leadboat.com> 2026-08-10 13:41 pgsql: Save/restore more lexer state when skipping text due to \if. Noah Misch <noah@leadboat.com> 2026-08-10 13:41 pgsql: Save/restore more lexer state when skipping text due to \if. Noah Misch <noah@leadboat.com> 2026-08-10 13:41 pgsql: Save/restore more lexer state when skipping text due to \if. Noah Misch <noah@leadboat.com>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox