cookie: simplify invalid_octets()

should also make it marginally faster and smaller.

Closes #16306
This commit is contained in:
Daniel Stenberg 2025-02-12 15:36:22 +01:00
parent 196e624471
commit 597ee915c4
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -461,15 +461,12 @@ static bool bad_domain(const char *domain, size_t len)
static bool invalid_octets(const char *p) static bool invalid_octets(const char *p)
{ {
/* Reject all bytes \x01 - \x1f (*except* \x09, TAB) + \x7f */ /* Reject all bytes \x01 - \x1f (*except* \x09, TAB) + \x7f */
static const char badoctets[] = { while(*p) {
"\x01\x02\x03\x04\x05\x06\x07\x08\x0a" if(((*p != 9) && (*p < 0x20)) || (*p == 0x7f))
"\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" return TRUE;
"\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f" p++;
}; }
size_t len; return FALSE;
/* scan for all the octets that are *not* in cookie-octet */
len = strcspn(p, badoctets);
return p[len] != '\0';
} }
#define CERR_OK 0 #define CERR_OK 0