We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 56fead4 commit 390b3cbCopy full SHA for 390b3cb
src/common/saslprep.c
@@ -1004,15 +1004,17 @@ pg_utf8_string_len(const char *source)
1004
const unsigned char *p = (const unsigned char *) source;
1005
int l;
1006
int num_chars = 0;
1007
+ size_t len = strlen(source);
1008
- while (*p)
1009
+ while (len)
1010
{
1011
l = pg_utf_mblen(p);
1012
- if (!pg_utf8_islegal(p, l))
1013
+ if (len < l || !pg_utf8_islegal(p, l))
1014
return -1;
1015
1016
p += l;
1017
+ len -= l;
1018
num_chars++;
1019
}
1020
0 commit comments