]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Henrik Nordstrom <henrik@henriknordstrom.net>
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 2 Oct 2009 08:49:33 +0000 (21:49 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 2 Oct 2009 08:49:33 +0000 (21:49 +1300)
Bug 2773: Segfault in RFC2069 Digest authantication

Squid segfaulted if digest authentication is enabled an a client responded
with RFC2069 style response.

lib/rfc2617.c
src/auth/digest/auth_digest.cc

index f653bca91c901d0386a89f477776a8b95c832157..a45a2af1de207ccba689116f2d3c279670c86406 100644 (file)
@@ -168,7 +168,7 @@ DigestCalcResponse(
     SquidMD5Update(&Md5Ctx, pszMethod, strlen(pszMethod));
     SquidMD5Update(&Md5Ctx, ":", 1);
     SquidMD5Update(&Md5Ctx, pszDigestUri, strlen(pszDigestUri));
-    if (strcasecmp(pszQop, "auth-int") == 0) {
+    if (pszQop && strcasecmp(pszQop, "auth-int") == 0) {
        SquidMD5Update(&Md5Ctx, ":", 1);
        SquidMD5Update(&Md5Ctx, HEntity, HASHHEXLEN);
     }
@@ -182,7 +182,7 @@ DigestCalcResponse(
     SquidMD5Update(&Md5Ctx, ":", 1);
     SquidMD5Update(&Md5Ctx, pszNonce, strlen(pszNonce));
     SquidMD5Update(&Md5Ctx, ":", 1);
-    if (*pszQop) {
+    if (pszQop) {
        SquidMD5Update(&Md5Ctx, pszNonceCount, strlen(pszNonceCount));
        SquidMD5Update(&Md5Ctx, ":", 1);
        SquidMD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce));
index 80f959d5ece8d0df5fa383b18e5215e78f73c670..585419676401c6840ef009226092d2a62d1c1ee9 100644 (file)
@@ -1105,6 +1105,7 @@ AuthDigestConfig::decode(char const *proxy_auth)
             /* quote mark */
             p++;
 
+            safe_free(username);
             username = xstrndup(p, strchr(p, '"') + 1 - p);
 
             debugs(29, 9, "authDigestDecodeAuth: Found Username '" << username << "'");
@@ -1117,6 +1118,7 @@ AuthDigestConfig::decode(char const *proxy_auth)
             /* quote mark */
             p++;
 
+            safe_free(digest_request->realm);
             digest_request->realm = xstrndup(p, strchr(p, '"') + 1 - p);
 
             debugs(29, 9, "authDigestDecodeAuth: Found realm '" << digest_request->realm << "'");
@@ -1130,6 +1132,7 @@ AuthDigestConfig::decode(char const *proxy_auth)
                 /* quote mark */
                 p++;
 
+            safe_free(digest_request->qop);
             digest_request->qop = xstrndup(p, strcspn(p, "\" \t\r\n()<>@,;:\\/[]?={}") + 1);
 
             debugs(29, 9, "authDigestDecodeAuth: Found qop '" << digest_request->qop << "'");
@@ -1143,6 +1146,7 @@ AuthDigestConfig::decode(char const *proxy_auth)
                 /* quote mark */
                 p++;
 
+            safe_free(digest_request->algorithm);
             digest_request->algorithm = xstrndup(p, strcspn(p, "\" \t\r\n()<>@,;:\\/[]?={}") + 1);
 
             debugs(29, 9, "authDigestDecodeAuth: Found algorithm '" << digest_request->algorithm << "'");
@@ -1155,6 +1159,7 @@ AuthDigestConfig::decode(char const *proxy_auth)
             /* quote mark */
             p++;
 
+            safe_free(digest_request->uri);
             digest_request->uri = xstrndup(p, strchr(p, '"') + 1 - p);
 
             debugs(29, 9, "authDigestDecodeAuth: Found uri '" << digest_request->uri << "'");
@@ -1167,6 +1172,7 @@ AuthDigestConfig::decode(char const *proxy_auth)
             /* quote mark */
             p++;
 
+            safe_free(digest_request->nonceb64);
             digest_request->nonceb64 = xstrndup(p, strchr(p, '"') + 1 - p);
 
             debugs(29, 9, "authDigestDecodeAuth: Found nonce '" << digest_request->nonceb64 << "'");
@@ -1188,6 +1194,7 @@ AuthDigestConfig::decode(char const *proxy_auth)
             /* quote mark */
             p++;
 
+            safe_free(digest_request->cnonce);
             digest_request->cnonce = xstrndup(p, strchr(p, '"') + 1 - p);
 
             debugs(29, 9, "authDigestDecodeAuth: Found cnonce '" << digest_request->cnonce << "'");
@@ -1200,6 +1207,7 @@ AuthDigestConfig::decode(char const *proxy_auth)
             /* quote mark */
             p++;
 
+            safe_free(digest_request->response);
             digest_request->response = xstrndup(p, strchr(p, '"') + 1 - p);
 
             debugs(29, 9, "authDigestDecodeAuth: Found response '" << digest_request->response << "'");