mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:35:08 +00:00
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
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
Add a link
Reference in a new issue