From cb52bfdd27f44ca1fe357120f388ac4bdf6d4f8d Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sun, 23 Aug 2020 15:55:49 +0200 Subject: [PATCH] Userland: Prefer strlcpy over strcpy in ping This is supposed to serve as a reminder if and when someone decides to make the 'msg' field configurable. --- Userland/ping.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/ping.cpp b/Userland/ping.cpp index 54fbf343bd..9096d0e470 100644 --- a/Userland/ping.cpp +++ b/Userland/ping.cpp @@ -125,7 +125,7 @@ int main(int argc, char** argv) ping_packet.header.code = 0; ping_packet.header.un.echo.id = htons(pid); ping_packet.header.un.echo.sequence = htons(seq++); - strcpy(ping_packet.msg, "Hello there!\n"); + strlcpy(ping_packet.msg, "Hello there!\n", sizeof(ping_packet.msg)); ping_packet.header.checksum = internet_checksum(&ping_packet, sizeof(PingPacket));