key check should use whole key length

This commit is contained in:
overflowerror 2021-06-12 17:54:47 +02:00
parent 9d0e533fa1
commit 70bf93a3ed

View file

@ -22,15 +22,16 @@ char* getCookie(ctx_t ctx, const char* key) {
char* value = NULL;
while((str = strtok_r(str, ";", saveptr)) != NULL) {
if (strncmp(str, key, keyLength) == 0) {
str = strtok_r(NULL, "=", saveptr)
if (str == NULL) {
// illegal cookie definition; ignore
} else {
value = str;
break;
}
while((str = strtok_r(str, "; ", saveptr)) != NULL) {
char* keyCandidate = str;
str = strtok_r(NULL, "=", saveptr);
if (str == NULL) {
// illegal cookie definition; ignore
continue;
}
if (strcmp(keyCandidate, key) == 0) {
value = str;
}
str = NULL;