]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUILD: proto_uxst: shut up yet another gcc's absurd warning
authorWilly Tarreau <w@1wt.eu>
Fri, 12 Jun 2020 13:58:19 +0000 (15:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 12 Jun 2020 14:15:44 +0000 (16:15 +0200)
commitf28d5c9ac6af9fc6cfb8efecdaa1a42b4a93d351
treeeca735dd7f3fcd5dfd6366f716dfe1bf55a42139
parentdb57a142c31016ff3e0dd533cb2b4de14445781e
BUILD: proto_uxst: shut up yet another gcc's absurd warning

When building with gcc-8 -fsanitize=address, we get this warning once on
an strncpy() call in proto_uxst.c:

  src/proto_uxst.c:262:3: warning: 'strncpy' output may be truncated copying 107 bytes from a string of length 4095 [-Wstringop-truncation]
     strncpy(addr.sun_path, tempname, sizeof(addr.sun_path) - 1);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It happens despite the test on snprintf() at the top (since gcc's string
handling is totally empiric), and requires the strlen() test to be placed
"very close" to the strncpy() call (with "very close" yet to be determined).
There's no other way to shut this one except disabling it. Given there's
only one instance of this warning and the cost of dealing with it in the
code is not huge, let's decorate the code to make gcc happily believe it
is smart since it seems to have a mind of itself.
src/proto_uxst.c