mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
dasdinfo: Fix format-overflow warning
Use snprintf() instead of sprintf() to avoid buffer overflow. Also change the integer type from signed to unsigned. Error: dasdinfo.c: In function 'dinfo_create_devnode': dasdinfo.c:297:52: warning: '%04d' directive writing between 4 and 11 bytes into a region of size 5 [-Wformat-overflow=] 297 | sprintf(filename, "dasdinfo%04d", retry); | ^~~~ Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Jan Polensky <japo@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
f4ee6c2c8d
commit
522c67a2c3
@@ -283,7 +283,7 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
|
||||
char filename[] = "dasdinfo0000";
|
||||
mode_t mode;
|
||||
unsigned int path;
|
||||
int retry;
|
||||
unsigned int retry;
|
||||
int rc;
|
||||
int fd;
|
||||
|
||||
@@ -294,7 +294,7 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
|
||||
if (pathname[path] == NULL)
|
||||
continue;
|
||||
for (retry = 0; retry < TEMP_DEV_MAX_RETRIES; retry++) {
|
||||
sprintf(filename, "dasdinfo%04d", retry);
|
||||
snprintf(filename, sizeof(filename), "dasdinfo%04d", retry);
|
||||
result = dinfo_make_path(pathname[path], filename);
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user