mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
With GCC 7 we get the following warning as a potential overflow might
happen, if d_name gets too big:
dasdinfo.c: In function 'main':
dasdinfo.c:611:37: warning: '%s' directive writing up to 255 bytes into
a region of size 69 [-Wformat-overflow=]
sprintf(sys_dev_path, "/sys/block/%s/dev", dir_entry->d_name);
^~
dasdinfo.c:611:3: note: 'sprintf' output between 16 and 271 bytes into a
destination of size 80
sprintf(sys_dev_path, "/sys/block/%s/dev", dir_entry->d_name);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This could be fixed by simply increasing the buffer size. However, there
is a little bit more to it and the way files are currently read can be
simplified.
Do this by using the libutil functions to read files and clean up a
little along the way.
Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>