diff options
author | Daniel Stenberg <daniel@haxx.se> | 2010-12-23 22:52:32 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2010-12-23 22:52:32 +0100 |
commit | 49465fffdb37b91ee5a0ad2601ea9657e5cd8915 (patch) | |
tree | 3be874f5ec5ccf85a2ab2a1f8d6b8f2f030d727e /lib/cookie.c | |
parent | 5825aa149dc74050bb329b4491b556c6095ac4a8 (diff) | |
download | curl-49465fffdb37b91ee5a0ad2601ea9657e5cd8915.tar.gz |
cookies: tricked dotcounter fixed
Providing multiple dots in a series in the domain field (domain=..com) could
trick the cookie engine to wrongly accept the cookie believing it to be
fine. Since the tailmatching would then match all .com sites, the cookie would
then be sent to all of them.
The code now requires at least one letter between each dot for them to be
counted. Edited test case 61 to verify this.
Diffstat (limited to 'lib/cookie.c')
-rw-r--r-- | lib/cookie.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/cookie.c b/lib/cookie.c index c6460a100..d40cbb8f8 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -270,6 +270,7 @@ Curl_cookie_add(struct SessionHandle *data, we don't care about that, we treat the names the same anyway */ const char *domptr=whatptr; + const char *nextptr; int dotcount=1; /* Count the dots, we need to make sure that there are enough @@ -280,12 +281,13 @@ Curl_cookie_add(struct SessionHandle *data, domptr++; do { - domptr = strchr(domptr, '.'); - if(domptr) { - domptr++; - dotcount++; + nextptr = strchr(domptr, '.'); + if(nextptr) { + if(domptr != nextptr) + dotcount++; + domptr = nextptr+1; } - } while(domptr); + } while(nextptr); /* The original Netscape cookie spec defined that this domain name MUST have three dots (or two if one of the seven holy TLDs), |