Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9fe0975

Browse files
committed
Avoid generating invalid character encoding sequences in make_greater_string.
Not sure how this mistake evaded detection for so long.
1 parentb8362d4 commit9fe0975

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

‎src/backend/utils/adt/selfuncs.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.155 2004/01/17 20:09:35 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.156 2004/02/02 03:07:08 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -3742,6 +3742,11 @@ pattern_selectivity(Const *patt, Pattern_Type ptype)
37423742
*
37433743
* This could be rather slow in the worst case, but in most cases we
37443744
* won't have to try more than one or two strings before succeeding.
3745+
*
3746+
* NOTE: at present this assumes we are in the C locale, so that simple
3747+
* bytewise comparison applies. However, we might be in a multibyte
3748+
* encoding such as UTF-8, so we do have to watch out for generating
3749+
* invalid encoding sequences.
37453750
*/
37463751
Const*
37473752
make_greater_string(constConst*str_const)
@@ -3788,13 +3793,20 @@ make_greater_string(const Const *str_const)
37883793
/*
37893794
* Try to generate a larger string by incrementing the last byte.
37903795
*/
3791-
if (*lastchar< (unsignedchar)255)
3796+
while (*lastchar< (unsignedchar)255)
37923797
{
37933798
Const*workstr_const;
37943799

37953800
(*lastchar)++;
3801+
37963802
if (datatype!=BYTEAOID)
3803+
{
3804+
/* do not generate invalid encoding sequences */
3805+
if (!pg_verifymbstr((constunsignedchar*)workstr,
3806+
len, true))
3807+
continue;
37973808
workstr_const=string_to_const(workstr,datatype);
3809+
}
37983810
else
37993811
workstr_const=string_to_bytea_const(workstr,len);
38003812

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp