]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix cachemgr.cgi regression in the bug 4957 fix (#741)
authorŠtěpán Brož <32738079+brozs@users.noreply.github.com>
Tue, 27 Oct 2020 10:29:18 +0000 (10:29 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Sun, 8 Nov 2020 04:12:20 +0000 (17:12 +1300)
After master commit 2e29287, authenticated CGI interface users could not
use the menu links (getting HTTP 403 error). Symptoms in cache.log:

    CacheManager: unknown@...: password needed for 'menu'
    CacheManager: <username>@...: incorrect password for 'menu'

tools/cachemgr.cc

index 942bf47f8bba411b4d28ae46ad662946b5879c06..78e6eff181487c7ef19165562334923d9d220728 100644 (file)
@@ -1092,14 +1092,20 @@ make_pub_auth(cachemgr_request * req)
     if (!req->passwd || !strlen(req->passwd))
         return;
 
+    auto *rfc1738_username = xstrdup(rfc1738_escape(safe_str(req->user_name)));
+    auto *rfc1738_passwd = xstrdup(rfc1738_escape(req->passwd));
+
     /* host | time | user | passwd */
     const int bufLen = snprintf(buf, sizeof(buf), "%s|%d|%s|%s",
                                 req->hostname,
                                 (int) now,
-                                rfc1738_escape(safe_str(req->user_name)),
-                                rfc1738_escape(req->passwd));
+                                rfc1738_username,
+                                rfc1738_passwd);
     debug("cmgr: pre-encoded for pub: %s\n", buf);
 
+    safe_free(rfc1738_username);
+    safe_free(rfc1738_passwd);
+
     const int encodedLen = base64_encode_len(bufLen);
     req->pub_auth = (char *) xmalloc(encodedLen);
     struct base64_encode_ctx ctx;