net: Fix usage of strncpy in net_if_get_name and net_if_set_name
Replaced with memcpy. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
40ee8791f2
commit
47396e18e1
1 changed files with 4 additions and 2 deletions
|
@ -4747,7 +4747,8 @@ int net_if_get_name(struct net_if *iface, char *buf, int len)
|
|||
return -ERANGE;
|
||||
}
|
||||
|
||||
strncpy(buf, net_if_get_config(iface)->name, name_len);
|
||||
/* Copy string and null terminator */
|
||||
memcpy(buf, net_if_get_config(iface)->name, name_len + 1);
|
||||
|
||||
return name_len;
|
||||
#else
|
||||
|
@ -4769,7 +4770,8 @@ int net_if_set_name(struct net_if *iface, const char *buf)
|
|||
return -ENAMETOOLONG;
|
||||
}
|
||||
|
||||
strncpy(net_if_get_config(iface)->name, buf, name_len);
|
||||
/* Copy string and null terminator */
|
||||
memcpy(net_if_get_config(iface)->name, buf, name_len + 1);
|
||||
|
||||
return 0;
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue