mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
lszcrypt: Replace sprintf() with util_asprintf()
Get rid of fixed buffers and avoid the following GCC8 compile warnings:
lszcrypt.c: In function ‘main’:
lszcrypt.c:642:28: warning: ‘%04x’ directive writing between 4 and 8
bytes into a region of size between 7 and 13 [-Wformat-overflow=]
sprintf(sub_dev, "%02x.%04x", id, dom);
^~~~
lszcrypt.c:642:22: note: directive argument in the range [0, 2147483647]
sprintf(sub_dev, "%02x.%04x", id, dom);
^~~~~~~~~~~
lszcrypt.c:642:5: note: ‘sprintf’ output between 8 and 18 bytes into a
destination of size 16
sprintf(sub_dev, "%02x.%04x", id, dom);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "lib/util_base.h"
|
||||
#include "lib/util_file.h"
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_opt.h"
|
||||
#include "lib/util_panic.h"
|
||||
#include "lib/util_path.h"
|
||||
@@ -620,7 +621,7 @@ static void show_devices_argv(char *argv[])
|
||||
{
|
||||
struct util_rec *rec = util_rec_new_wide("-");
|
||||
struct dirent **dev_vec, **subdev_vec;
|
||||
char *ap, *grp_dev, *path, card[16], sub_dev[16];
|
||||
char *ap, *grp_dev, *path, *card, *sub_dev;
|
||||
int id, dom, i, n, dev_cnt, sub_cnt;
|
||||
|
||||
/* check if ap driver is available */
|
||||
@@ -639,14 +640,16 @@ static void show_devices_argv(char *argv[])
|
||||
if (sscanf(argv[i], "%x.%x", &id, &dom) >= 1) {
|
||||
/* at least the id field was valid */
|
||||
if (id >= 0 && dom >= 0) { /* single subdevice */
|
||||
sprintf(sub_dev, "%02x.%04x", id, dom);
|
||||
util_asprintf(&sub_dev, "%02x.%04x", id, dom);
|
||||
grp_dev = util_path_sysfs("devices/ap/card%02x",
|
||||
id);
|
||||
show_subdevice(rec, grp_dev, sub_dev);
|
||||
free(grp_dev);
|
||||
free(sub_dev);
|
||||
} else { /* group device */
|
||||
sprintf(card, "card%02x", id);
|
||||
util_asprintf(&card, "card%02x", id);
|
||||
show_device(rec, card);
|
||||
free(card);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user