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

Commitb527394

Browse files
committed
Ensure maxlen is at leat 1 in dict_int
The dict_int text search dictionary template accepts maxlen parameter,which is then used to cap the length of input strings. The value wasnot properly checked, and the code simply does txt[d->maxlen] = '\0';to insert a terminator, leading to segfaults with negative values.This commit simply rejects values less than 1. The issue was there sincedct_int was introduced in 9.3, so backpatch all the way back to 9.4which is the oldest supported version.Reported-by: ciliDiscussion:https://postgr.es/m/16144-a36a5bef7657047d@postgresql.orgBackpatch-through: 9.4
1 parentbf39b3a commitb527394

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

‎contrib/dict_int/dict_int.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ dintdict_init(PG_FUNCTION_ARGS)
4545
if (strcmp(defel->defname,"maxlen")==0)
4646
{
4747
d->maxlen=atoi(defGetString(defel));
48+
49+
if (d->maxlen<1)
50+
ereport(ERROR,
51+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
52+
errmsg("maxlen value has to be >= 1")));
4853
}
4954
elseif (strcmp(defel->defname,"rejectlong")==0)
5055
{

‎contrib/dict_int/expected/dict_int.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,5 @@ select ts_lexize('intdict', '314532610153');
300300
{314532}
301301
(1 row)
302302

303+
ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = -214783648);
304+
ERROR: maxlen value has to be >= 1

‎contrib/dict_int/sql/dict_int.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ select ts_lexize('intdict', '252281774');
5151
select ts_lexize('intdict','313425');
5252
select ts_lexize('intdict','641439323669');
5353
select ts_lexize('intdict','314532610153');
54+
55+
ALTERTEXT SEARCH DICTIONARY intdict (MAXLEN=-214783648);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp