mirror of
https://github.com/sigmasternchen/CShore
synced 2025-03-15 08:08:56 +00:00
key check should use whole key length
This commit is contained in:
parent
9d0e533fa1
commit
70bf93a3ed
1 changed files with 10 additions and 9 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue