Skip to content

Commit 5f1dbd4

Browse files
committed
Avoid compile warning -Wstringop-overflow
1 parent 6df10cf commit 5f1dbd4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

proxy/src/proxy_server.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,13 @@ void proxy_server::udp_tproxy_forward_packet_http(
19331933
pos += varint_int_encode(1 + len, buf + pos); // capsule length
19341934
pos += varint_int_encode(0, buf + pos); // context ID
19351935

1936+
if (pos + len > sizeof(buf))
1937+
{
1938+
XLOG_WARN << "tproxy flow: " << flow->flow_key_
1939+
<< ", capsule too large: " << (pos + len);
1940+
return;
1941+
}
1942+
19361943
std::memcpy(buf + pos, data, len); // UDP payload
19371944
pos += len;
19381945

0 commit comments

Comments
 (0)