Skip to content

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

@noloader

Description

@noloader

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
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions