Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error: '%s' directive writing up to 63 bytes into a region of size between 53 and 179 [-Werror=format-overflow=] #19

Open
archibate opened this issue Mar 27, 2020 · 3 comments

Comments

@archibate
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of shadowsocks-libev are you using?

shadowsocksr-libev 2.4.1.366.gbf324d8-1 (2020年03月27日 星期五 12时59分51秒)

What operating system are you using?

Archlinux 64bit.

What did you do?

Install shadowsocksr-libev from AUR using yaourt (i.e. compile from source).

What did you expect to see?

Install success.

What did you see instead?

acl.c: In function 'init_block_list':
acl.c:74:90: error: '%s' directive writing up to 63 bytes into a region of size between 50 and 176 [-Werror=format-overflow=]
   74 |     "ip6tables -N %s; ip6tables -F %s; ip6tables -A OUTPUT -p tcp --tcp-flags RST RST -j %s";
      |                                                                                          ^~
......
  158 |         sprintf(cli, ip6tables_init_chain, chain_name, chain_name, chain_name);
      |                                                                    ~~~~~~~~~~             
In file included from /usr/include/stdio.h:867,
                 from ../libipset/include/ipset/ipset.h:14,
                 from acl.c:23:
/usr/include/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 81 and 270 bytes into a destination of size 256
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acl.c:67:87: error: '%s' directive writing up to 63 bytes into a region of size between 53 and 179 [-Werror=format-overflow=]
   67 |     "iptables -N %s; iptables -F %s; iptables -A OUTPUT -p tcp --tcp-flags RST RST -j %s";
      |                                                                                       ^~
......
  160 |         sprintf(cli, iptables_init_chain, chain_name, chain_name, chain_name);
      |                                                                   ~~~~~~~~~~           
In file included from /usr/include/stdio.h:867,
                 from ../libipset/include/ipset/ipset.h:14,
                 from acl.c:23:
/usr/include/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 78 and 267 bytes into a destination of size 256
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acl.c:92:5: error: ';      firewall-cmd --direct...' directive writing 88 bytes into a region of size between 33 and 159 [-Werror=format-overflow=]
   92 |     "firewall-cmd --direct --add-chain ipv6 filter %s; \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   93 |      firewall-cmd --direct --passthrough ipv6 -F %s; \
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   94 |      firewall-cmd --direct --passthrough ipv6 -A OUTPUT -p tcp --tcp-flags RST RST -j %s";
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:867,
                 from ../libipset/include/ipset/ipset.h:14,
                 from acl.c:23:
/usr/include/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 186 and 375 bytes into a destination of size 256
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acl.c:81:5: error: ';      firewall-cmd --direct...' directive writing 88 bytes into a region of size between 33 and 159 [-Werror=format-overflow=]
   81 |     "firewall-cmd --direct --add-chain ipv4 filter %s; \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   82 |      firewall-cmd --direct --passthrough ipv4 -F %s; \
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   83 |      firewall-cmd --direct --passthrough ipv4 -A OUTPUT -p tcp --tcp-flags RST RST -j %s";
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:867,
                 from ../libipset/include/ipset/ipset.h:14,
                 from acl.c:23:
/usr/include/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 186 and 375 bytes into a destination of size 256
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acl.c: In function 'free_block_list':
acl.c:96:5: error: '%s' directive writing up to 63 bytes into a region of size between 61 and 124 [-Werror=format-overflow=]
   96 |     "firewall-cmd --direct --passthrough ipv6 -D OUTPUT -p tcp --tcp-flags RST RST -j %s; \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   97 |      firewall-cmd --direct --passthrough ipv6 -F %s; \
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   98 |      firewall-cmd --direct --remove-chain ipv6 filter %s";
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
  184 |         sprintf(cli, firewalld6_remove_chain, chain_name, chain_name, chain_name);
      |                                                           ~~~~~~~~~~
In file included from /usr/include/stdio.h:867,
                 from ../libipset/include/ipset/ipset.h:14,
                 from acl.c:23:
/usr/include/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 189 and 378 bytes into a destination of size 256
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acl.c:85:5: error: '%s' directive writing up to 63 bytes into a region of size between 61 and 124 [-Werror=format-overflow=]
   85 |     "firewall-cmd --direct --passthrough ipv4 -D OUTPUT -p tcp --tcp-flags RST RST -j %s; \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   86 |      firewall-cmd --direct --passthrough ipv4 -F %s; \
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   87 |      firewall-cmd --direct --remove-chain ipv4 filter %s";
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
  186 |         sprintf(cli, firewalld_remove_chain, chain_name, chain_name, chain_name);
      |                                                          ~~~~~~~~~~
In file included from /usr/include/stdio.h:867,
                 from ../libipset/include/ipset/ipset.h:14,
                 from acl.c:23:
/usr/include/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 189 and 378 bytes into a destination of size 256
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acl.c:76:90: error: '%s' directive writing up to 63 bytes into a region of size between 50 and 176 [-Werror=format-overflow=]
   76 |     "ip6tables -D OUTPUT -p tcp --tcp-flags RST RST -j %s; ip6tables -F %s; ip6tables -X %s";
      |                                                                                          ^~
......
  179 |         sprintf(cli, ip6tables_remove_chain, chain_name, chain_name, chain_name);
      |                                                                      ~~~~~~~~~~           
In file included from /usr/include/stdio.h:867,
                 from ../libipset/include/ipset/ipset.h:14,
                 from acl.c:23:
/usr/include/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 81 and 270 bytes into a destination of size 256
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acl.c:69:87: error: '%s' directive writing up to 63 bytes into a region of size between 53 and 179 [-Werror=format-overflow=]
   69 |     "iptables -D OUTPUT -p tcp --tcp-flags RST RST -j %s; iptables -F %s; iptables -X %s";
      |                                                                                       ^~
......
  181 |         sprintf(cli, iptables_remove_chain, chain_name, chain_name, chain_name);
      |                                                                     ~~~~~~~~~~         
In file included from /usr/include/stdio.h:867,
                 from ../libipset/include/ipset/ipset.h:14,
                 from acl.c:23:
/usr/include/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 78 and 267 bytes into a destination of size 256
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:778:libshadowsocks_libev_la-acl.lo] 错误 1
make[2]: 离开目录“/tmp/yaourt-tmp-bate/aur-shadowsocksr-libev/src/shadowsocksr-libev/src”
make[1]: *** [Makefile:478:all-recursive] 错误 1
make[1]: 离开目录“/tmp/yaourt-tmp-bate/aur-shadowsocksr-libev/src/shadowsocksr-libev”
make: *** [Makefile:387:all] 错误 2

What is your config in detail (with all sensitive info masked)?

Not installed yet.

@Evsio0n
Copy link

Evsio0n commented Mar 31, 2020

Looks like I got a same issue here.

@huihuimoe
Copy link

Have you tried the solution in the comments under the aur package page?
link below:
https://aur.archlinux.org/packages/shadowsocksr-libev-git/

gcc8及以上需要修改CFLAGS如下, export CFLAGS="${CFLAGS} -Wall -O3 -pipe -Wno-format-truncation -Wno-error=format-overflow -Wno-error=pointer-arith -Wno-error=stringop-truncation -Wno-error=sizeof-pointer-memaccess"

@Evsio0n
Copy link

Evsio0n commented Mar 31, 2020

It looks nice. Thanks.

Have you tried the solution in the comments under the aur package page?
link below:
https://aur.archlinux.org/packages/shadowsocksr-libev-git/

gcc8及以上需要修改CFLAGS如下, export CFLAGS="${CFLAGS} -Wall -O3 -pipe -Wno-format-truncation -Wno-error=format-overflow -Wno-error=pointer-arith -Wno-error=stringop-truncation -Wno-error=sizeof-pointer-memaccess"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants