Skip to content

Commit 730e21c

Browse files
rmetrichrousskov
authored andcommitted
Fix parsing of legacy url_rewrite_program responses
Legacy helper responses start with a URL instead of `OK rewrite_url=...` and such. 2016 commit ddc77a2 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 commit resurrects recent commit bb854bb that was accidentally reverted by commit ec328cf during pull request merging by Anubis.
1 parent 992fb27 commit 730e21c

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ Thank you!
439439
Regents of the University of California (UCSD)
440440
Reinhard Posmyk <Reinhard.Posmyk@arxes.de>
441441
Reinhard Sojka <reinhard.sojka@parlament.gv.at>
442+
Renaud Metrich <renaud.metrich@gmail.com>
442443
Rene Geile <rene.geile@t-online.de>
443444
Reuben Farrelly <reuben@reub.net>
444445
Ricardo Ferreira Ribeiro <garb12@pm.me>

src/redirect.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ redirectHandleReply(void *data, const Helper::Reply &reply)
110110
// parse it into status=, url= and rewrite-url= keys
111111
if (replySize) {
112112
MemBuf replyBuffer;
113-
replyBuffer.init(replySize, replySize);
114-
replyBuffer.append(reply.other().content(), reply.other().contentSize());
113+
replyBuffer.init(replySize + 1, replySize + 1); // with space for 0-terminator added by append()
114+
Assure(replySize <= size_t(reply.other().contentSize()));
115+
replyBuffer.append(reply.other().content(), replySize);
115116
char * result = replyBuffer.content();
116117

117118
Helper::Reply newReply;

0 commit comments

Comments
 (0)