summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2020-08-23 13:34:58 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-24 00:45:03 +0200
commit46b04a79e5c3c6be649b0d1a791fa9e91a0cbb50 (patch)
tree4f568326a8be9035343e6d32051abc5ed9e986b4
parente682967d7eb4bff978b011b03a6bf4b939745d1c (diff)
downloadserenity-46b04a79e5c3c6be649b0d1a791fa9e91a0cbb50.zip
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).
-rw-r--r--Services/DHCPClient/DHCPv4Client.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Services/DHCPClient/DHCPv4Client.cpp b/Services/DHCPClient/DHCPv4Client.cpp
index 918a20b93f..8b8e6b228c 100644
--- a/Services/DHCPClient/DHCPv4Client.cpp
+++ b/Services/DHCPClient/DHCPv4Client.cpp
@@ -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;