From a6cfe704289795740709dd2397c2a43646ca2d6e Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 17 Apr 2023 16:38:52 +0100 Subject: internal: avoid buffer overflows with socket paths --- hyprctl/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hyprctl/main.cpp') diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp index 7c939a4c..87c332fb 100644 --- a/hyprctl/main.cpp +++ b/hyprctl/main.cpp @@ -80,7 +80,7 @@ void request(std::string arg, int minArgs = 0) { std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.socket.sock"; - strcpy(serverAddress.sun_path, socketPath.c_str()); + strncpy(serverAddress.sun_path, socketPath.c_str(), 107); if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { std::cout << "Couldn't connect to " << socketPath << ". (3)"; @@ -143,7 +143,7 @@ void requestHyprpaper(std::string arg) { std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.hyprpaper.sock"; - strcpy(serverAddress.sun_path, socketPath.c_str()); + strncpy(serverAddress.sun_path, socketPath.c_str(), 107); if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { std::cout << "Couldn't connect to " << socketPath << ". (3)"; -- cgit v1.2.3