You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2021/02/23 17:45:16 UTC
[trafficserver] branch 9.1.x updated: Avoid -Warray-bounds on PROXY
Protocol Builder (#7488)
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.1.x by this push:
new f5ac0f5 Avoid -Warray-bounds on PROXY Protocol Builder (#7488)
f5ac0f5 is described below
commit f5ac0f5200327ae00216f314a5009091df164843
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Tue Feb 9 07:49:10 2021 +0900
Avoid -Warray-bounds on PROXY Protocol Builder (#7488)
(cherry picked from commit f658828f3ba38482aadc218eb060fae9ce22d58a)
---
iocore/net/ProxyProtocol.cc | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/iocore/net/ProxyProtocol.cc b/iocore/net/ProxyProtocol.cc
index 1d406a7..9cf4c8e 100644
--- a/iocore/net/ProxyProtocol.cc
+++ b/iocore/net/ProxyProtocol.cc
@@ -62,6 +62,8 @@ constexpr uint16_t PPv2_ADDR_LEN_INET = 4 + 4 + 2 + 2;
constexpr uint16_t PPv2_ADDR_LEN_INET6 = 16 + 16 + 2 + 2;
constexpr uint16_t PPv2_ADDR_LEN_UNIX = 108 + 108;
+const ts::BWFSpec ADDR_ONLY_FMT{"::a"};
+
struct PPv2Hdr {
uint8_t sig[12]; ///< preface
uint8_t ver_cmd; ///< protocol version and command
@@ -334,19 +336,11 @@ proxy_protocol_v1_build(uint8_t *buf, size_t max_buf_len, const ProxyProtocol &p
bw.write(PPv1_DELIMITER);
// the layer 3 source address
- char src_ip_buf[INET6_ADDRSTRLEN];
- ats_ip_ntop(pp_info.src_addr, src_ip_buf, sizeof(src_ip_buf));
- size_t src_ip_len = strnlen(src_ip_buf, sizeof(src_ip_buf));
-
- bw.write(src_ip_buf, src_ip_len);
+ bwformat(bw, ADDR_ONLY_FMT, pp_info.src_addr);
bw.write(PPv1_DELIMITER);
// the layer 3 destination address
- char dst_ip_buf[INET6_ADDRSTRLEN];
- ats_ip_ntop(pp_info.dst_addr, dst_ip_buf, sizeof(dst_ip_buf));
- size_t dst_ip_len = strnlen(dst_ip_buf, sizeof(dst_ip_buf));
-
- bw.write(dst_ip_buf, dst_ip_len);
+ bwformat(bw, ADDR_ONLY_FMT, pp_info.dst_addr);
bw.write(PPv1_DELIMITER);
// TCP source port