DHCPClient: Prefer strlcpy over strncpy, fixes off-by-one
A malicious caller of set_params could have caused the ifr_name field to lack NUL-termination. I don't think this was an actual problem, though, as the Kernel always forces NUL-termination by overwriting ifr_name's last byte with NUL. However, it feels better to do it properly. No behaviour change (probably).
This commit is contained in:
parent
e682967d7e
commit
46b04a79e5
Notes:
sideshowbarker
2024-07-19 03:14:15 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/46b04a79e5c Pull-request: https://github.com/SerenityOS/serenity/pull/3275 Reviewed-by: https://github.com/awesomekling
1 changed files with 1 additions and 1 deletions
|
@ -70,7 +70,7 @@ static void set_params(const InterfaceDescriptor& iface, const IPv4Address& ipv4
|
|||
|
||||
struct ifreq ifr;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
strncpy(ifr.ifr_name, iface.m_ifname.characters(), IFNAMSIZ);
|
||||
strlcpy(ifr.ifr_name, iface.m_ifname.characters(), IFNAMSIZ);
|
||||
|
||||
// set the IP address
|
||||
ifr.ifr_addr.sa_family = AF_INET;
|
||||
|
|
Loading…
Add table
Reference in a new issue