mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 17:10:12 +01:00
platform: assert for valid ifname in ethtool_get()
Add an assert (g_return_val_if_reached()) that the interface name is valid and shorter then 16 bytes. If it happened to be longer, strncpy() would not have zero terminated the interface name.
This commit is contained in:
parent
904e961464
commit
5b123f2539
1 changed files with 4 additions and 1 deletions
|
|
@ -48,8 +48,11 @@ ethtool_get (const char *name, gpointer edata)
|
|||
if (!name || !*name)
|
||||
return FALSE;
|
||||
|
||||
if (strlen (name) >= IFNAMSIZ)
|
||||
g_return_val_if_reached (FALSE);
|
||||
|
||||
memset (&ifr, 0, sizeof (ifr));
|
||||
strncpy (ifr.ifr_name, name, IFNAMSIZ);
|
||||
strcpy (ifr.ifr_name, name);
|
||||
ifr.ifr_data = edata;
|
||||
|
||||
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue