mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
dasdinfo: fix buffer overflow warning
Fix a possible buffer overflow.
The buffer overflow is only theoretical since the device name is max
8 characters in length.
This fixes following gcc 7 warning:
dasdinfo.c: In function 'main':
dasdinfo.c:576:33: warning: '%s' directive writing up to 255 bytes into a
region of size 69 [-Wformat-overflow=]
sprintf(*uidfile,"/sys/block/%s/device/uid",
^~
In file included from /usr/include/stdio.h:862:0,
from dasdinfo.c:15:
/usr/include/bits/stdio2.h:33:10: note: '__builtin___sprintf_chk' output
between 23 and 278 bytes into a destination of size 80
return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
This commit is contained in:
committed by
Michael Holzheu
parent
70243b8135
commit
3c80f7e025
@@ -573,8 +573,8 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
|
||||
|
||||
if (strncmp(stat_dev, readbuf,
|
||||
MAX(strlen(stat_dev), strlen(readbuf)-1)) == 0) {
|
||||
sprintf(*uidfile,"/sys/block/%s/device/uid",
|
||||
dir_entry->d_name);
|
||||
snprintf(*uidfile, RD_BUFFER_SIZE,
|
||||
"/sys/block/%s/device/uid", dir_entry->d_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user