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

Commit390b3cb

Browse files
Protect against small overread in SASLprep validation
In case of torn UTF8 in the input data we might end up goingpast the end of the string since we don't account for length.While validation won't be performed on a sequence with a NULLbyte it's better to avoid going past the end to beging with.Fix by taking the length into consideration.Author: Jacob Champion <jacob.champion@enterprisedb.com>Reviewed-by: Daniel Gustafsson <daniel@yesql.se>Discussion:https://postgr.es/m/CAOYmi+mTnmM172g=_+Yvc47hzzeAsYPy2C4UBY3HK9p-AXNV0g@mail.gmail.com
1 parent56fead4 commit390b3cb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎src/common/saslprep.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,15 +1004,17 @@ pg_utf8_string_len(const char *source)
10041004
constunsignedchar*p= (constunsignedchar*)source;
10051005
intl;
10061006
intnum_chars=0;
1007+
size_tlen=strlen(source);
10071008

1008-
while (*p)
1009+
while (len)
10091010
{
10101011
l=pg_utf_mblen(p);
10111012

1012-
if (!pg_utf8_islegal(p,l))
1013+
if (len<l||!pg_utf8_islegal(p,l))
10131014
return-1;
10141015

10151016
p+=l;
1017+
len-=l;
10161018
num_chars++;
10171019
}
10181020

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp