[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

daemon/remote.c:965:38: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character #169

Closed
noloader opened this issue Feb 27, 2020 · 2 comments

Comments

@noloader
Copy link
Contributor
noloader commented Feb 27, 2020

Hi Everyone,

I'm working from master and using instrumented builds. Building on Ubuntu 18.04 with UBsan:

libtool: compile:  gcc -I. -DSRCDIR=. -DNDEBUG -g2 -O3 -fsanitize=undefined -fno-sanitize-recover -pthread -c daemon/remote.c  -fPIC -DPIC -o .libs/remote.o
...
daemon/remote.c: In function ‘do_stats’:
daemon/remote.c:965:38: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=]
    snprintf(nm, sizeof(nm), "OPCODE%d", i);
                                      ^
In file included from /usr/include/stdio.h:862:0,
                 from ./config.h:1022,
                 from daemon/remote.c:45:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 8 and 17 bytes into a destination of size 16
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can setup the test rig by exporting CFLAGS with UBsan enabled:

$ git clone https://github.com/NLnetLabs/unbound.git
$ cd unbound
$ export CFLAGS="-DNDEBUG -g2 -O3 -fsanitize=undefined -fno-sanitize-recover"
$ ./make-master.sh
...
$ make test
...
@wcawijngaards
Copy link
Member

Thanks, I guess the buffer increase in the commit 348e246 should do the trick. Nice that it tests for potential buffer exceeded for the fixed strings. In practice this statistics counter probably does not get to maxint, but it is good to fix anyway.

@noloader
Copy link
Contributor Author

Thanks @wcawijngaards.

Yeah, this is one of those annoying squawks, like a little dog that nips at your ankles.

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

2 participants