Avoid 8bit overflow in is_public_suffix()

This commit is contained in:
Tim Rühsen 2022-01-16 12:51:33 +01:00
parent 042c586371
commit 55d0ae04de
1 changed files with 4 additions and 1 deletions

View File

@ -835,8 +835,11 @@ static int is_public_suffix(const psl_ctx_t *psl, const char *domain, int type)
suffix.nlabels = 1;
for (p = domain; *p; p++) {
if (*p == '.')
if (*p == '.') {
if (suffix.nlabels == 255) // weird input, avoid 8bit overflow
return 0;
suffix.nlabels++;
}
else if (*((unsigned char *)p) >= 128)
need_conversion = 1; /* in case domain is non-ascii we need a toASCII conversion */
}