mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
net: niu: fix potential buffer overflow/truncation in irq names
Building with W=1 reports a -Wformat-truncation warning on niu_set_irq_name(): the "%s:SYSERR" format could be truncated because irq_name[] was one byte too small for the worst case interface name length (IFNAMSIZ-1) plus the ":SYSERR" suffix. Increase the irq_name buffer size to account for the suffix and replace the remaining sprintf() calls in the same function with snprintf() to avoid possible buffer overflows. Tested: - Built the kernel with W=1 and confirmed the warning is no longer reported. - No NIU hardware was available for runtime testing. Signed-off-by: Ronan Marchal <ronanmarchal29@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260803211149.10585-1-ronanmarchal29@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
0200d48477
commit
4d8e0becfd
|
|
@ -6021,11 +6021,11 @@ static void niu_set_irq_name(struct niu *np)
|
|||
int port = np->port;
|
||||
int i, j = 1;
|
||||
|
||||
sprintf(np->irq_name[0], "%s:MAC", np->dev->name);
|
||||
snprintf(np->irq_name[0], sizeof(np->irq_name[0]), "%s:MAC", np->dev->name);
|
||||
|
||||
if (port == 0) {
|
||||
sprintf(np->irq_name[1], "%s:MIF", np->dev->name);
|
||||
sprintf(np->irq_name[2], "%s:SYSERR", np->dev->name);
|
||||
snprintf(np->irq_name[1], sizeof(np->irq_name[1]), "%s:MIF", np->dev->name);
|
||||
snprintf(np->irq_name[2], sizeof(np->irq_name[2]), "%s:SYSERR", np->dev->name);
|
||||
j = 3;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3262,7 +3262,7 @@ struct niu {
|
|||
#define NIU_FLAGS_XMAC 0x00010000 /* 0=BMAC 1=XMAC */
|
||||
|
||||
u32 msg_enable;
|
||||
char irq_name[NIU_NUM_RXCHAN+NIU_NUM_TXCHAN+3][IFNAMSIZ + 6];
|
||||
char irq_name[NIU_NUM_RXCHAN + NIU_NUM_TXCHAN + 3][IFNAMSIZ + 7];
|
||||
|
||||
/* Protects hw programming, and ring state. */
|
||||
spinlock_t lock;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user