[BUG] http: the request URI pointer is relative to the buffer
The rq.u field is relative to buf->data, not to msg->sol. We have
to subtract msg->som everywhere this error was made. Maybe it will
be simpler to have a pointer to the buffer in the message and find
appropriate data there.
diff --git a/src/proto_http.c b/src/proto_http.c
index e1c4414..536f358 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -593,7 +593,7 @@
{
char *ptr, *end;
- ptr = txn->req.sol + txn->req.sl.rq.u;
+ ptr = txn->req.sol - txn->req.som + txn->req.sl.rq.u;
end = ptr + txn->req.sl.rq.u_l;
if (ptr >= end)
@@ -661,7 +661,7 @@
if (!path)
return;
- len = txn->req.sl.rq.u_l + (txn->req.sol+txn->req.sl.rq.u) - path;
+ len = txn->req.sl.rq.u_l + (txn->req.sol-txn->req.som+txn->req.sl.rq.u) - path;
if (rdr.len + len > rdr.size - 4) /* 4 for CRLF-CRLF */
return;
@@ -2730,7 +2730,7 @@
path = http_get_path(txn);
/* build message using path */
if (path) {
- pathlen = txn->req.sl.rq.u_l + (txn->req.sol+txn->req.sl.rq.u) - path;
+ pathlen = txn->req.sl.rq.u_l + (txn->req.sol-txn->req.som+txn->req.sl.rq.u) - path;
if (rule->flags & REDIRECT_FLAG_DROP_QS) {
int qs = 0;
while (qs < pathlen) {
@@ -6234,7 +6234,7 @@
return 0;
test->len = txn->req.sl.rq.u_l;
- test->ptr = txn->req.sol + txn->req.sl.rq.u;
+ test->ptr = txn->req.sol - txn->req.som + txn->req.sl.rq.u;
/* we do not need to set READ_ONLY because the data is in a buffer */
test->flags = ACL_TEST_F_VOL_1ST;
@@ -6258,7 +6258,7 @@
return 0;
/* Parse HTTP request */
- url2sa(txn->req.sol + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &l4->srv_addr);
+ url2sa(txn->req.sol - txn->req.som + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &l4->srv_addr);
test->ptr = (void *)&((struct sockaddr_in *)&l4->srv_addr)->sin_addr;
test->i = AF_INET;
@@ -6290,7 +6290,7 @@
return 0;
/* Same optimization as url_ip */
- url2sa(txn->req.sol + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &l4->srv_addr);
+ url2sa(txn->req.sol - txn->req.som + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &l4->srv_addr);
test->i = ntohs(((struct sockaddr_in *)&l4->srv_addr)->sin_port);
if (px->options & PR_O_HTTP_PROXY)
@@ -6577,7 +6577,7 @@
/* ensure the indexes are not affected */
return 0;
- end = txn->req.sol + txn->req.sl.rq.u + txn->req.sl.rq.u_l;
+ end = txn->req.sol - txn->req.som + txn->req.sl.rq.u + txn->req.sl.rq.u_l;
ptr = http_get_path(txn);
if (!ptr)
return 0;