Skip to content

Commit 0b8e893

Browse files
rousskovsquid-anubis
authored andcommitted
Re-fix parsing of legacy url_rewrite_program responses (#2446)
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 change resurrects recent commit bb854bb that was accidentally reverted by commit ec328cf during pull request merging by Anubis.
1 parent acdf34e commit 0b8e893

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
@@ -440,6 +440,7 @@ Thank you!
440440
Reinhard Posmyk <Reinhard.Posmyk@arxes.de>
441441
Reinhard Sojka <reinhard.sojka@parlament.gv.at>
442442
Renan Rodrigo <rr@ubuntu.com>
443+
Renaud Metrich <renaud.metrich@gmail.com>
443444
Rene Geile <rene.geile@t-online.de>
444445
Reuben Farrelly <reuben@reub.net>
445446
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)