mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-27 03:40:42 +02: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.
(cherry picked from commit 5b123f2539)
This commit is contained in:
parent
5b71ec822a
commit
796f78a04c
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