Skip to content

Commit e5eb949

Browse files
committed
Correct the use of snprintf in owinterface_add
The origin size value of snprintf in owinterface_add was ETH_ALEN, if the string size is too large, it will only allow ETH_ALEN - 1 characters to be copied into the buffer. However, the buffer starts from location inf_name + 1 and the last character must be '\0', which means that the buffer only has at most ETH_ALEN - 2 characters space left. So the size value in snprintf of owinterface_add should be ETH_ALEN - 1
1 parent 3db379f commit e5eb949

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

vwifi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ static struct wireless_dev *owinterface_add(struct wiphy *wiphy, int if_idx)
12161216
* address (the first byte of multicast addrs is odd).
12171217
*/
12181218
char intf_name[ETH_ALEN] = {0};
1219-
snprintf(intf_name + 1, ETH_ALEN, "%s%d", NAME_PREFIX, if_idx);
1219+
snprintf(intf_name + 1, ETH_ALEN - 1, "%s%d", NAME_PREFIX, if_idx);
12201220

12211221
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
12221222
eth_hw_addr_set(vif->ndev, intf_name);

0 commit comments

Comments
 (0)