You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by GitBox <gi...@apache.org> on 2021/02/05 17:18:35 UTC

[GitHub] [trafficserver] bneradt commented on issue #7487: An array-bounds warning on PROXY Protocol Builder

bneradt commented on issue #7487:
URL: https://github.com/apache/trafficserver/issues/7487#issuecomment-774168514


   In case it's helpful, I also reproduce this locally with g++ 9.3.1 (I originally observed this in 8.x):
   
   ```
   $ pwd
   /home/bneradt/repos/ts_os_master_use_new_pv_202/iocore/net
   
   $ c++ --version
   c++ (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
   Copyright (C) 2019 Free Software Foundation, Inc.
   This is free software; see the source for copying conditions.  There is NO
   warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   
   $ c++ -DHAVE_CONFIG_H -I. -I../../include  -Dlinux -D_LARGEFILE64_SOURCE=1 -D_COMPILE64BIT_SOURCE=1 -D_REENTRANT -D__STDC_LIMIT_MACROS=1 -D__STDC_FORMAT_MACROS=1 -I/home/bneradt/repos/ts_os_master_use_new_pv_202/iocore/eventsystem -I/home/bneradt/repos/ts_os_master_use_new_pv_202/iocore/net -I/home/bneradt/repos/ts_os_master_use_new_pv_202/iocore/net/quic -I/home/bneradt/repos/ts_os_master_use_new_pv_202/iocore/aio -I/home/bneradt/repos/ts_os_master_use_new_pv_202/iocore/hostdb -I/home/bneradt/repos/ts_os_master_use_new_pv_202/iocore/cache -I/home/bneradt/repos/ts_os_master_use_new_pv_202/iocore/utils -I/home/bneradt/repos/ts_os_master_use_new_pv_202/iocore/dns -I/home/bneradt/repos/ts_os_master_use_new_pv_202/include -I/home/bneradt/repos/ts_os_master_use_new_pv_202/lib -I/home/bneradt/repos/ts_os_master_use_new_pv_202/proxy -I/home/bneradt/repos/ts_os_master_use_new_pv_202/proxy/hdrs -I/home/bneradt/repos/ts_os_master_use_new_pv_202/proxy/shared -I/home/bneradt/repos/ts_os_maste
 r_use_new_pv_202/proxy/logging -I/home/bneradt/repos/ts_os_master_use_new_pv_202/mgmt -I/home/bneradt/repos/ts_os_master_use_new_pv_202/mgmt/utils -I/home/bneradt/repos/ts_os_master_use_new_pv_202/proxy/http  -I/opt/oath/openssl/1.1.1//include -I/home/bneradt/repos/ts_os_master_use_new_pv_202/lib/yamlcpp/include -D_GNU_SOURCE -I/opt/oath/openssl/1.1.1//include -DOPENSSL_NO_SSL_INTERN -std=c++17 -g -pipe -Wall -Wextra -Wno-ignored-qualifiers -Wno-unused-parameter -Wno-format-truncation -Wno-cast-function-type -Wno-stringop-overflow -O3 -feliminate-unused-debug-symbols -fno-strict-aliasing -Wno-invalid-offsetof -Wno-noexcept-type -mcx16  -MT ProxyProtocol.o -MD -MP -MF $depbase.Tpo -c -o ProxyProtocol.o ProxyProtocol.cc
   In file included from ProxyProtocol.cc:29:
   In member function ‘virtual ts::FixedBufferWriter& ts::FixedBufferWriter::write(const void*, size_t)’,
       inlined from ‘size_t {anonymous}::proxy_protocol_v1_build(uint8_t*, size_t, const ProxyProtocol&)’ at ProxyProtocol.cc:341:34,
       inlined from ‘size_t proxy_protocol_build(uint8_t*, size_t, const ProxyProtocol&, ProxyProtocolVersion)’ at ProxyProtocol.cc:492:34:
   ../../include/tscore/BufferWriter.h:264:20: warning: ‘void* memcpy(void*, const void*, size_t)’ forming offset [47, 94] is out of the bounds [0, 46] of object ‘src_ip_buf’ with type ‘char [46]’ [-Warray-bounds]
     264 |         std::memcpy(_buf + _attempted, data, _capacity - _attempted);
         |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   ProxyProtocol.cc: In function ‘size_t proxy_protocol_build(uint8_t*, size_t, const ProxyProtocol&, ProxyProtocolVersion)’:
   ProxyProtocol.cc:337:8: note: ‘src_ip_buf’ declared here
     337 |   char src_ip_buf[INET6_ADDRSTRLEN];
         |        ^~~~~~~~~~
   
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org