mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Fix rewrite and over-long header handling on Windows
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Waiting to run
Update HTML documentation / docs (push) Has been cancelled
Update wiki / wiki (push) Has been cancelled
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Waiting to run
Update HTML documentation / docs (push) Has been cancelled
Update wiki / wiki (push) Has been cancelled
op_rewrite checked what it built with targetunsafe(), which describes a path on this machine: on Windows it must name a drive or a share, so a rewritten request path was refused and every rewrite rule failed there. A rewrite produces a request path and is checked as one. The header loop stopped at HTTPSRV_MAXHDR and answered anyway, leaving the rest of the request in the stream for the next one to be read out of. It refuses the request instead. A header longer than the buffer arrives as several lines, so the count bounds what is read rather than what a client may send in one header. The test for the buffer growth after a PCRE rewrite sent its request through to an httpsrv origin, which stops reading at that same cap; it uses an origin which reads whatever it is sent, since what is under test is the proxy in the middle.
This commit is contained in:
1 parent
5400d53cef
commit
f265ea0b52
3 files changed
+43
-14
No files matched your search
+18
-8
@@ -198,14 +198,24 @@ def run(t):
|
||||
# GHSA-h845-prxq-ww3q: a rewrite that doubles the client headers used to
|
||||
# leave a buffer holding exactly what it produced, and the Content-Length
|
||||
# the data filter regenerates was then written past the end of it.
|
||||
p = proxy_with("rewrite_grow",
|
||||
'pcre_rewrite cliheader dunno "(?s).*" "$0$0"',
|
||||
'pcre clidata dunno *')
|
||||
big = "".join("X-%d: %s\r\n" % (i, chr(65 + i) * 20000) for i in range(5))
|
||||
reply = t.raw_proxy_request(p, url + "/echo", extra=big, body="z")
|
||||
t.contains(reply, "200", "a doubled header block with a body is answered")
|
||||
t.contains(t.http(url + "/echo", proxy=p), "path=/echo",
|
||||
"and the proxy is still there afterwards")
|
||||
# The origin here reads whatever it is sent and answers the same way every
|
||||
# time: what is being tested is the proxy in the middle, not what a server
|
||||
# is willing to accept in one request.
|
||||
grown = t.free_port()
|
||||
stop = t.raw_server(grown, b"HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nok",
|
||||
drain=True)
|
||||
try:
|
||||
p = proxy_with("rewrite_grow",
|
||||
'pcre_rewrite cliheader dunno "(?s).*" "$0$0"',
|
||||
'pcre clidata dunno *')
|
||||
big = "".join("X-%d: %s\r\n" % (i, chr(65 + i) * 20000) for i in range(5))
|
||||
reply = t.raw_proxy_request(p, f"http://127.0.0.1:{grown}/x",
|
||||
extra=big, body="z")
|
||||
t.contains(reply, "200", "a doubled header block with a body is answered")
|
||||
t.contains(t.raw_proxy_request(p, f"http://127.0.0.1:{grown}/x"), "200",
|
||||
"and the proxy is still there afterwards")
|
||||
finally:
|
||||
stop()
|
||||
|
||||
# A reference to a group the pattern does not have is dropped, and dropped
|
||||
# by both the pass which measures the result and the pass which writes it.
|
||||
|
||||
Reference in new issue
Block a user