Address GCC 8 compilation warnings
GCC 8.1.0 on Arch Linux emits some compilation warnings that were not triggered by GCC 7.3.1 on the same system:
- in
bin/named/server.c
:
./server.c: In function ‘named_server_zonestatus’:
./server.c:13990:11: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 512 [-Wformat-truncation=]
"%s/%s", namebuf, typebuf);
^- -------
./server.c:13989:4: note: ‘snprintf’ output between 2 and 1035 bytes into a destination of size 512
snprintf(resignbuf, sizeof(resignbuf),
^-------------------------------------
"%s/%s", namebuf, typebuf);
--------------------------
- in
bin/tests/system/dlzexternal/driver.c
:
driver.c: In function ‘dlz_lookup’:
driver.c:424:3: warning: ‘strncpy’ output may be truncated copying 255 bytes from a string of length 255 [-Wstringop-truncation]
strncpy(last, full_name, 255);
^----------------------------
- in
lib/dns/dnssec.c
:
dnssec.c: In function ‘dns_dnssec_findzonekeys’:
dnssec.c:800:21: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 242 [-Wformat-truncation=]
"key file for %s/%s/%d",
^-
namebuf, algbuf, dst_key_id(pubkey));
-------
dnssec.c:800:7: note: directive argument in the range [0, 65535]
"key file for %s/%s/%d",
^----------------------
dnssec.c:799:5: note: ‘snprintf’ output between 17 and 1063 bytes into a destination of size 255
snprintf(filename, sizeof(filename) - 1,
^---------------------------------------
"key file for %s/%s/%d",
------------------------
namebuf, algbuf, dst_key_id(pubkey));
------------------------------------
dnssec.c: In function ‘dns_dnssec_keylistfromrdataset’:
dnssec.c:1692:21: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 242 [-Wformat-truncation=]
"key file for %s/%s/%d",
^-
namebuf, algbuf, dst_key_id(pubkey));
-------
dnssec.c:1692:7: note: directive argument in the range [0, 65535]
"key file for %s/%s/%d",
^----------------------
dnssec.c:1691:5: note: ‘snprintf’ output between 17 and 1063 bytes into a destination of size 255
snprintf(filename, sizeof(filename) - 1,
^---------------------------------------
"key file for %s/%s/%d",
------------------------
namebuf, algbuf, dst_key_id(pubkey));
------------------------------------
- in
lib/dns/rdata/generic/loc_29.c
:
In file included from code.h:56,
from rdata.c:560:
rdata/generic/loc_29.c: In function ‘totext_loc.isra.328’:
rdata/generic/loc_29.c:558:60: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
"%d %d %d.%03d %s %d %d %d.%03d %s %s%lu.%02lum %s %s %s",
^
rdata/generic/loc_29.c:557:2: note: ‘snprintf’ output between 33 and 75 bytes into a destination of size 74
snprintf(buf, sizeof(buf),
^-------------------------
"%d %d %d.%03d %s %d %d %d.%03d %s %s%lu.%02lum %s %s %s",
----------------------------------------------------------
d1, m1, s1, fs1, north ? "N" : "S",
-----------------------------------
d2, m2, s2, fs2, east ? "E" : "W",
----------------------------------
below ? "-" : "", altitude/100, altitude % 100,
-----------------------------------------------
sbuf, hbuf, vbuf);
-----------------
- in
lib/isc/{unix,win32}/file.c
:
file.c: In function 'isc_file_sanitize':
file.c:742:36: error: '%s' directive output may be truncated writing up to 1 bytes into a region of size between 0 and 4096 [-Werror=format-truncation=]
snprintf(buf, sizeof(buf), "%s%s%s%s%s",
^-
file.c:742:2: note: 'snprintf' output 1 or more bytes (assuming 4098) into a destination of size 4096
snprintf(buf, sizeof(buf), "%s%s%s%s%s",
^---------------------------------------
dir != NULL ? dir : "", dir != NULL ? "/" : "",
-----------------------------------------------
hash, ext != NULL ? "." : "", ext != NULL ? ext : "");
-----------------------------------------------------
file.c:752:36: error: '%s' directive output may be truncated writing up to 1 bytes into a region of size between 0 and 4096 [-Werror=format-truncation=]
snprintf(buf, sizeof(buf), "%s%s%s%s%s",
^-
file.c:752:2: note: 'snprintf' output 1 or more bytes (assuming 4098) into a destination of size 4096
snprintf(buf, sizeof(buf), "%s%s%s%s%s",
^---------------------------------------
dir != NULL ? dir : "", dir != NULL ? "/" : "",
-----------------------------------------------
hash, ext != NULL ? "." : "", ext != NULL ? ext : "");
-----------------------------------------------------
- in
lib/ns/notify.c
:
notify.c: In function ‘ns_notify_start’:
notify.c:128:53: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size between 0 and 1023 [-Wformat-truncation=]
snprintf(tsigbuf, sizeof(tsigbuf), ": TSIG '%s' (%s)",
^-
namebuf, cnamebuf);
--------
notify.c:128:4: note: ‘snprintf’ output between 13 and 2059 bytes into a destination of size 1034
snprintf(tsigbuf, sizeof(tsigbuf), ": TSIG '%s' (%s)",
^-----------------------------------------------------
namebuf, cnamebuf);
------------------
None of these look serious to me. AFAICT, the worst case scenario is truncated output.