From eca35e8be385f53a29c46c01be1b87eac895b645 Mon Sep 17 00:00:00 2001 From: Nikolay Ivanuschak Date: Mon, 18 Dec 2023 22:20:50 +0300 Subject: [PATCH] core: fixed haproxy protocol parser fixes GH #3683 --- src/core/tcp_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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;