]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cookie: expire cookies at once when max-age is negative
authorDaniel Stenberg <daniel@haxx.se>
Thu, 17 Nov 2022 07:26:17 +0000 (08:26 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 17 Nov 2022 12:47:24 +0000 (13:47 +0100)
Update test 329 to verify

Reported-by: godmar on github
Fixes #9930
Closes #9932

lib/cookie.c
tests/data/test329

index 4d81344ba79045af41d37038853817abc4cb94f3..1cc923f8fbbff0d3233fbe6eda97eacc62904965 100644 (file)
@@ -779,10 +779,16 @@ Curl_cookie_add(struct Curl_easy *data,
       offt = curlx_strtoofft((*co->maxage == '\"')?
                              &co->maxage[1]:&co->maxage[0], NULL, 10,
                              &co->expires);
-      if(offt == CURL_OFFT_FLOW)
+      switch(offt) {
+      case CURL_OFFT_FLOW:
         /* overflow, used max value */
         co->expires = CURL_OFF_T_MAX;
-      else if(!offt) {
+        break;
+      case CURL_OFFT_INVAL:
+        /* negative or otherwise bad, expire */
+        co->expires = 1;
+        break;
+      case CURL_OFFT_OK:
         if(!co->expires)
           /* already expired */
           co->expires = 1;
@@ -791,6 +797,7 @@ Curl_cookie_add(struct Curl_easy *data,
           co->expires = CURL_OFF_T_MAX;
         else
           co->expires += now;
+        break;
       }
     }
     else if(co->expirestr) {
index d25f9689050c48b96fb8b057dc1ca987d211c2be..86f7a82751270e109e77809d3c1ba6d7e57df36f 100644 (file)
@@ -14,6 +14,7 @@ Date: Tue, 09 Nov 2010 14:49:00 GMT
 Server: test-server/fake\r
 Content-Type: text/html\r
 Funny-head: yesyes\r
+Set-Cookie: testn1=yes; path=/we/want/; domain=.host.foo.com; Max-Age=-1;\r
 Set-Cookie: test=yes; path=/we/want/; domain=.host.foo.com; Max-Age=0;\r
 Content-Length: 4\r
 \r