Files
s390-tools/dasdinfo
Jan Höppner 1261105fe2 dasdinfo: Fix truncation warning
Commit 3c80f7e025 ("dasdinfo: fix buffer overflow warning") changed a
sprintf call to snprintf to avoid a buffer overflow warning. However,
GCC 7 now warns about a potential truncation with snprintf:

dasdinfo.c: In function 'main':
dasdinfo.c:577:18: warning: '%s' directive output may be truncated
writing up to 255 bytes into a region of size 69 [-Wformat-truncation=]
      "/sys/block/%s/device/uid", dir_entry->d_name);
                  ^~
dasdinfo.c:576:4: note: 'snprintf' output between 23 and 278 bytes into
a destination of size 80
    snprintf(*uidfile, RD_BUFFER_SIZE,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "/sys/block/%s/device/uid", dir_entry->d_name);
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We could get around this by increasing the buffer. Though, the current
buffer size is already plenty and we know better anyway.
Avoid the warning by simply checking the return value of snprintf and
display an error in case data was truncated nonetheless.

Fixes: 3c80f7e025 ("dasdinfo: fix buffer overflow warning")
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-18 16:58:49 +02:00
..
2017-08-21 10:55:40 +02:00
2017-10-18 16:58:49 +02:00
2017-08-21 10:55:40 +02:00