]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #2773: Segfault in RFC2069 Digest authantication
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Fri, 25 Sep 2009 01:15:30 +0000 (03:15 +0200)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Fri, 25 Sep 2009 01:15:30 +0000 (03:15 +0200)
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 5895421e0a1228634d53de979b88547460279906..f7530d6c552b4effd4a09b5a66ebdae3c8e18524 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 9cdcaa9927cc7337b8e3de65719e4456cfcd3740..d482cfbae7ecdeb4ad10cd34b44915559794023c 100644 (file)
@@ -1106,6 +1106,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 << "'");
@@ -1118,6 +1119,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 << "'");
@@ -1131,6 +1133,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 << "'");
@@ -1144,6 +1147,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 << "'");
@@ -1156,6 +1160,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 << "'");
@@ -1168,6 +1173,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 << "'");
@@ -1189,6 +1195,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 << "'");
@@ -1201,6 +1208,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 << "'");