haad / proxychains

proxychains - a tool that forces any TCP connection made by any given application to follow through proxy like TOR or any other SOCKS4, SOCKS5 or HTTP(S) proxy. Supported auth-types: "user/pass" for SOCKS4/5, "basic" for HTTP.
http://proxychains.sourceforge.net/
GNU General Public License v2.0
6.27k stars 603 forks source link

Compiling with -Wall causes stringop-truncation error #118

Open viking opened 2 years ago

viking commented 2 years ago

After running ./configure and make, here's what happened:

cc -MD -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror   -DLIB_DIR=\"/usr/local/lib\" -DINSTALL_PREFIX=\"/usr/local\" -DDLL_NAME=\"libproxychains4.so\" -DSYSCONFDIR=\"/usr/local/etc\"  -fPIC -c -o src/core.o src/core.c
src/core.c: In function ‘proxy_gethostbyname’:
src/core.c:832:9: error: ‘strncpy’ specified bound 8192 equals destination size [-Werror=stringop-truncation]
  832 |         strncpy(data->addr_name, name, sizeof(data->addr_name));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/core.c: In function ‘proxy_getaddrinfo’:
src/core.c:917:17: error: ‘strncpy’ specified bound 256 equals destination size [-Werror=stringop-truncation]
  917 |                 strncpy(space->addr_name, node, sizeof(space->addr_name));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:65: src/core.o] Error 1

Here's my gcc version:

gcc (GCC) 11.1.1 20210531 (Red Hat 11.1.1-3)
Copyright (C) 2021 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.
javabeanz commented 2 years ago

same here. gcc version 11.2.1 20211203 (Red Hat 11.2.1-7) (GCC)

LuomingXu commented 2 years ago

https://stackoverflow.com/questions/50198319/gcc-8-wstringop-truncation-what-is-the-good-practice

modify src/core.c

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(data->addr_name, name, sizeof(data->addr_name));
#pragma GCC diagnostic pop

same for strncpy(space->addr_name, node, sizeof(space->addr_name));