* Handle bad cookies without crashing
[citadel.git] / webcit / auth.c
index 2f3d61bd82c30c99d9f49ccb446838bcb0d572be..61d7ecc00db16599fab3e0a04c9a93a8d8549d74 100644 (file)
@@ -996,13 +996,13 @@ void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
        if (hdr->DontNeedAuth)
                return;
 */
-       hdr->RawCookie = Line;
-
-       pch = strstr(ChrPtr(hdr->RawCookie), "webcit=");
-       
-       if (pch != NULL)
-               StrBufCutLeft(hdr->RawCookie, (pch - ChrPtr(hdr->RawCookie)) + 7);
+       pch = strstr(ChrPtr(Line), "webcit=");
+       if (pch == NULL) {
+               return;
+       }
 
+       hdr->RawCookie = Line;
+       StrBufCutLeft(hdr->RawCookie, (pch - ChrPtr(hdr->RawCookie)) + 7);
        StrBufDecodeHex(hdr->RawCookie);
 
        if (hdr->c_username == NULL)