Skip to content

Commit ca082f0

Browse files
tititiou36davem330
authored andcommitted
net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show()
strncat() usage in adf7242_debugfs_init() is wrong. The size given to strncat() is the maximum number of bytes that can be written, excluding the trailing NULL. Here, the size that is passed, DNAME_INLINE_LEN, does not take into account the size of "adf7242-" that is already in the array. In order to fix it, use snprintf() instead. Fixes: 7302b9d ("ieee802154/adf7242: Driver for ADF7242 MAC IEEE802154") Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 965f9b8 commit ca082f0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/ieee802154/adf7242.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,9 +1162,10 @@ static int adf7242_stats_show(struct seq_file *file, void *offset)
11621162

11631163
static void adf7242_debugfs_init(struct adf7242_local *lp)
11641164
{
1165-
char debugfs_dir_name[DNAME_INLINE_LEN + 1] = "adf7242-";
1165+
char debugfs_dir_name[DNAME_INLINE_LEN + 1];
11661166

1167-
strncat(debugfs_dir_name, dev_name(&lp->spi->dev), DNAME_INLINE_LEN);
1167+
snprintf(debugfs_dir_name, sizeof(debugfs_dir_name),
1168+
"adf7242-%s", dev_name(&lp->spi->dev));
11681169

11691170
lp->debugfs_root = debugfs_create_dir(debugfs_dir_name, NULL);
11701171

0 commit comments

Comments
 (0)