]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Re-fix parsing of legacy url_rewrite_program responses (#2446) auto master
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 22 Jun 2026 20:10:29 +0000 (20:10 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Mon, 22 Jun 2026 20:33:04 +0000 (20:33 +0000)
Legacy helper responses start with a URL instead of `OK rewrite_url=...`
and such. 2016 commit ddc77a2e introduced two bugs when handling legacy
responses:

* Response parsing code triggered MemBuf assertions when 0-terminating
  the parsing buffer for certain URLs. The bug affected legacy helper
  responses with and without space characters.

* Squid code attempted to accept/use helper-returned URLs with embedded
  space character(s), despite a WARNING implying that the post-space
  characters are not going to become a part of the new URL.

----

This change resurrects recent commit bb854bb9 that was accidentally
reverted by commit ec328cf16 during pull request merging by Anubis.

CONTRIBUTORS
src/redirect.cc

index 8596f0b2e198b6666aafd59cd83bee46f50c2c4f..23334bd09c38893ef2105b3e61bebecf192aa754 100644 (file)
@@ -440,6 +440,7 @@ Thank you!
     Reinhard Posmyk <Reinhard.Posmyk@arxes.de>
     Reinhard Sojka <reinhard.sojka@parlament.gv.at>
     Renan Rodrigo <rr@ubuntu.com>
+    Renaud Metrich <renaud.metrich@gmail.com>
     Rene Geile <rene.geile@t-online.de>
     Reuben Farrelly <reuben@reub.net>
     Ricardo Ferreira Ribeiro <garb12@pm.me>
index 14a102714772c39c6b1f1bb2b35680bf3c5cc2ac..528fed105dcca00be845b4f8cf37cebfb018b5c3 100644 (file)
@@ -110,8 +110,9 @@ redirectHandleReply(void *data, const Helper::Reply &reply)
             // parse it into status=, url= and rewrite-url= keys
             if (replySize) {
                 MemBuf replyBuffer;
-                replyBuffer.init(replySize, replySize);
-                replyBuffer.append(reply.other().content(), reply.other().contentSize());
+                replyBuffer.init(replySize + 1, replySize + 1); // with space for 0-terminator added by append()
+                Assure(replySize <= size_t(reply.other().contentSize()));
+                replyBuffer.append(reply.other().content(), replySize);
                 char * result = replyBuffer.content();
 
                 Helper::Reply newReply;