Module: kamailio
Branch: master
Commit: c5237830f3e7fbeec403a0190471a066081c1117
URL:
https://github.com/kamailio/kamailio/commit/c5237830f3e7fbeec403a0190471a06…
Author: Nikolay Ivanuschak <ivanuschak.nikolay(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-12-28T11:05:14+01:00
core: fixed haproxy protocol parser
fixes GH #3683
---
Modified: src/core/tcp_main.c
---
Diff:
https://github.com/kamailio/kamailio/commit/c5237830f3e7fbeec403a0190471a06…
Patch:
https://github.com/kamailio/kamailio/commit/c5237830f3e7fbeec403a0190471a06…
---
diff --git a/src/core/tcp_main.c b/src/core/tcp_main.c
index 4972b7d20af..35034d1baa8 100644
--- a/src/core/tcp_main.c
+++ b/src/core/tcp_main.c
@@ -1018,12 +1018,12 @@ int tcpconn_read_haproxy(struct tcp_connection *c)
src_ip->af = AF_INET;
src_ip->len = 4;
src_ip->u.addr32[0] = hdr.v2.addr.ip4.src_addr;
- c->rcv.src_port = hdr.v2.addr.ip4.src_port;
+ c->rcv.src_port = htons(hdr.v2.addr.ip4.src_port);
dst_ip->af = AF_INET;
dst_ip->len = 4;
dst_ip->u.addr32[0] = hdr.v2.addr.ip4.dst_addr;
- c->rcv.dst_port = hdr.v2.addr.ip4.dst_port;
+ c->rcv.dst_port = htons(hdr.v2.addr.ip4.dst_port);
goto done;
@@ -1031,12 +1031,12 @@ int tcpconn_read_haproxy(struct tcp_connection *c)
src_ip->af = AF_INET6;
src_ip->len = 16;
memcpy(src_ip->u.addr, hdr.v2.addr.ip6.src_addr, 16);
- c->rcv.src_port = hdr.v2.addr.ip6.src_port;
+ c->rcv.src_port = htons(hdr.v2.addr.ip6.src_port);
dst_ip->af = AF_INET6;
dst_ip->len = 16;
- memcpy(dst_ip->u.addr, hdr.v2.addr.ip6.src_addr, 16);
- c->rcv.dst_port = hdr.v2.addr.ip6.dst_port;
+ memcpy(dst_ip->u.addr, hdr.v2.addr.ip6.dst_addr, 16);
+ c->rcv.dst_port = htons(hdr.v2.addr.ip6.dst_port);
goto done;