agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Fix calculating length of match to localized month/weekday names 7+ messages / 1 participants [nested] [flat]
* pgsql: Fix calculating length of match to localized month/weekday names @ 2026-08-05 13:58 Álvaro Herrera <alvherre@kurilemu.de> 0 siblings, 0 replies; 7+ messages in thread From: Álvaro Herrera @ 2026-08-05 13:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix calculating length of match to localized month/weekday names seq_search_localized() returns the length of the matching prefix in *len, but because it internally case-folds the inputs, it gets confused on the length. The caller expects to get the length of the prefix in the original string, but what it actually returns is the length of the prefix after case-folding, which can be different if the case-folded characters have different byte-length than the original, or with ICU, if the case-folding changes the number of characters (e.g. "ß", the German double s). To fix, once we have determined that we have a match, work harder to find the match's length in the original string. This adds some overhead, but the strings are expected to be short. The function does "case-folding" by converting a string to upper-case, then to lower-case, which is a little ugly given that we have dedicated functions for case-folding nowadays. But switching to that doesn't seem appropriate to backpatch in a security fix, and that's not available in older stable versions, anyway. Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> Reported-by: Xint Code Reviewed-by: Jeff Davis <pgsql@j-davis.com> Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/fd2b89854d93d70fe8c9a69d5b8fafd5b9302cfc Modified Files -------------- src/backend/utils/adt/formatting.c | 146 ++++++++++++++++++++--- src/test/regress/expected/collate.linux.utf8.out | 18 +++ src/test/regress/sql/collate.linux.utf8.sql | 3 + 3 files changed, 150 insertions(+), 17 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix calculating length of match to localized month/weekday names @ 2026-08-05 13:58 Álvaro Herrera <alvherre@kurilemu.de> 0 siblings, 0 replies; 7+ messages in thread From: Álvaro Herrera @ 2026-08-05 13:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix calculating length of match to localized month/weekday names seq_search_localized() returns the length of the matching prefix in *len, but because it internally case-folds the inputs, it gets confused on the length. The caller expects to get the length of the prefix in the original string, but what it actually returns is the length of the prefix after case-folding, which can be different if the case-folded characters have different byte-length than the original, or with ICU, if the case-folding changes the number of characters (e.g. "ß", the German double s). To fix, once we have determined that we have a match, work harder to find the match's length in the original string. This adds some overhead, but the strings are expected to be short. The function does "case-folding" by converting a string to upper-case, then to lower-case, which is a little ugly given that we have dedicated functions for case-folding nowadays. But switching to that doesn't seem appropriate to backpatch in a security fix, and that's not available in older stable versions, anyway. Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> Reported-by: Xint Code Reviewed-by: Jeff Davis <pgsql@j-davis.com> Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/55ea764269b6fe8b3fcc221a970c09e12ef7a96b Modified Files -------------- src/backend/utils/adt/formatting.c | 146 ++++++++++++++++++++--- src/test/regress/expected/collate.linux.utf8.out | 18 +++ src/test/regress/sql/collate.linux.utf8.sql | 3 + 3 files changed, 150 insertions(+), 17 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix calculating length of match to localized month/weekday names @ 2026-08-05 13:58 Álvaro Herrera <alvherre@kurilemu.de> 0 siblings, 0 replies; 7+ messages in thread From: Álvaro Herrera @ 2026-08-05 13:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix calculating length of match to localized month/weekday names seq_search_localized() returns the length of the matching prefix in *len, but because it internally case-folds the inputs, it gets confused on the length. The caller expects to get the length of the prefix in the original string, but what it actually returns is the length of the prefix after case-folding, which can be different if the case-folded characters have different byte-length than the original, or with ICU, if the case-folding changes the number of characters (e.g. "ß", the German double s). To fix, once we have determined that we have a match, work harder to find the match's length in the original string. This adds some overhead, but the strings are expected to be short. The function does "case-folding" by converting a string to upper-case, then to lower-case, which is a little ugly given that we have dedicated functions for case-folding nowadays. But switching to that doesn't seem appropriate to backpatch in a security fix, and that's not available in older stable versions, anyway. Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> Reported-by: Xint Code Reviewed-by: Jeff Davis <pgsql@j-davis.com> Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/011384ba45fe193131f92c2d16c45f20d909301d Modified Files -------------- src/backend/utils/adt/formatting.c | 163 +++++++++++++++++++---- src/test/regress/expected/collate.linux.utf8.out | 18 +++ src/test/regress/sql/collate.linux.utf8.sql | 3 + 3 files changed, 158 insertions(+), 26 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix calculating length of match to localized month/weekday names @ 2026-08-05 13:58 Álvaro Herrera <alvherre@kurilemu.de> 0 siblings, 0 replies; 7+ messages in thread From: Álvaro Herrera @ 2026-08-05 13:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix calculating length of match to localized month/weekday names seq_search_localized() returns the length of the matching prefix in *len, but because it internally case-folds the inputs, it gets confused on the length. The caller expects to get the length of the prefix in the original string, but what it actually returns is the length of the prefix after case-folding, which can be different if the case-folded characters have different byte-length than the original, or with ICU, if the case-folding changes the number of characters (e.g. "ß", the German double s). To fix, once we have determined that we have a match, work harder to find the match's length in the original string. This adds some overhead, but the strings are expected to be short. The function does "case-folding" by converting a string to upper-case, then to lower-case, which is a little ugly given that we have dedicated functions for case-folding nowadays. But switching to that doesn't seem appropriate to backpatch in a security fix, and that's not available in older stable versions, anyway. Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> Reported-by: Xint Code Reviewed-by: Jeff Davis <pgsql@j-davis.com> Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8acfaa12a4c795304c623bf62e7e07693ec14f50 Modified Files -------------- src/backend/utils/adt/formatting.c | 137 +++++++++++++++++++---- src/test/regress/expected/collate.linux.utf8.out | 18 +++ src/test/regress/sql/collate.linux.utf8.sql | 3 + 3 files changed, 138 insertions(+), 20 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix calculating length of match to localized month/weekday names @ 2026-08-05 13:58 Álvaro Herrera <alvherre@kurilemu.de> 0 siblings, 0 replies; 7+ messages in thread From: Álvaro Herrera @ 2026-08-05 13:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix calculating length of match to localized month/weekday names seq_search_localized() returns the length of the matching prefix in *len, but because it internally case-folds the inputs, it gets confused on the length. The caller expects to get the length of the prefix in the original string, but what it actually returns is the length of the prefix after case-folding, which can be different if the case-folded characters have different byte-length than the original, or with ICU, if the case-folding changes the number of characters (e.g. "ß", the German double s). To fix, once we have determined that we have a match, work harder to find the match's length in the original string. This adds some overhead, but the strings are expected to be short. The function does "case-folding" by converting a string to upper-case, then to lower-case, which is a little ugly given that we have dedicated functions for case-folding nowadays. But switching to that doesn't seem appropriate to backpatch in a security fix, and that's not available in older stable versions, anyway. Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> Reported-by: Xint Code Reviewed-by: Jeff Davis <pgsql@j-davis.com> Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b594efe52b4cbf952e63805078df4e28ff634c76 Modified Files -------------- src/backend/utils/adt/formatting.c | 137 +++++++++++++++++++---- src/test/regress/expected/collate.linux.utf8.out | 18 +++ src/test/regress/sql/collate.linux.utf8.sql | 3 + 3 files changed, 138 insertions(+), 20 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix calculating length of match to localized month/weekday names @ 2026-08-05 13:58 Álvaro Herrera <alvherre@kurilemu.de> 0 siblings, 0 replies; 7+ messages in thread From: Álvaro Herrera @ 2026-08-05 13:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix calculating length of match to localized month/weekday names seq_search_localized() returns the length of the matching prefix in *len, but because it internally case-folds the inputs, it gets confused on the length. The caller expects to get the length of the prefix in the original string, but what it actually returns is the length of the prefix after case-folding, which can be different if the case-folded characters have different byte-length than the original, or with ICU, if the case-folding changes the number of characters (e.g. "ß", the German double s). To fix, once we have determined that we have a match, work harder to find the match's length in the original string. This adds some overhead, but the strings are expected to be short. The function does "case-folding" by converting a string to upper-case, then to lower-case, which is a little ugly given that we have dedicated functions for case-folding nowadays. But switching to that doesn't seem appropriate to backpatch in a security fix, and that's not available in older stable versions, anyway. Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> Reported-by: Xint Code Reviewed-by: Jeff Davis <pgsql@j-davis.com> Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0de744cd5281021c96ce7366efae2b17321909f8 Modified Files -------------- src/backend/utils/adt/formatting.c | 137 +++++++++++++++++++---- src/test/regress/expected/collate.linux.utf8.out | 18 +++ src/test/regress/sql/collate.linux.utf8.sql | 3 + 3 files changed, 138 insertions(+), 20 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix calculating length of match to localized month/weekday names @ 2026-08-05 13:58 Álvaro Herrera <alvherre@kurilemu.de> 0 siblings, 0 replies; 7+ messages in thread From: Álvaro Herrera @ 2026-08-05 13:58 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix calculating length of match to localized month/weekday names seq_search_localized() returns the length of the matching prefix in *len, but because it internally case-folds the inputs, it gets confused on the length. The caller expects to get the length of the prefix in the original string, but what it actually returns is the length of the prefix after case-folding, which can be different if the case-folded characters have different byte-length than the original, or with ICU, if the case-folding changes the number of characters (e.g. "ß", the German double s). To fix, once we have determined that we have a match, work harder to find the match's length in the original string. This adds some overhead, but the strings are expected to be short. The function does "case-folding" by converting a string to upper-case, then to lower-case, which is a little ugly given that we have dedicated functions for case-folding nowadays. But switching to that doesn't seem appropriate to backpatch in a security fix, and that's not available in older stable versions, anyway. Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> Reported-by: Xint Code Reviewed-by: Jeff Davis <pgsql@j-davis.com> Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/49a712f32ceebfeecac9017a49f5b1fe89ae399f Modified Files -------------- src/backend/utils/adt/formatting.c | 137 +++++++++++++++++++---- src/test/regress/expected/collate.linux.utf8.out | 18 +++ src/test/regress/sql/collate.linux.utf8.sql | 3 + 3 files changed, 138 insertions(+), 20 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2026-08-05 13:58 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-08-05 13:58 pgsql: Fix calculating length of match to localized month/weekday names Álvaro Herrera <alvherre@kurilemu.de> 2026-08-05 13:58 pgsql: Fix calculating length of match to localized month/weekday names Álvaro Herrera <alvherre@kurilemu.de> 2026-08-05 13:58 pgsql: Fix calculating length of match to localized month/weekday names Álvaro Herrera <alvherre@kurilemu.de> 2026-08-05 13:58 pgsql: Fix calculating length of match to localized month/weekday names Álvaro Herrera <alvherre@kurilemu.de> 2026-08-05 13:58 pgsql: Fix calculating length of match to localized month/weekday names Álvaro Herrera <alvherre@kurilemu.de> 2026-08-05 13:58 pgsql: Fix calculating length of match to localized month/weekday names Álvaro Herrera <alvherre@kurilemu.de> 2026-08-05 13:58 pgsql: Fix calculating length of match to localized month/weekday names Álvaro Herrera <alvherre@kurilemu.de>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox