refactor: replace strcpy with snprintf
This commit is contained in:
parent
ce076927f3
commit
8fc4187713
|
@ -166,9 +166,13 @@ std::string IPC::getSocket1Reply(const std::string& rq) {
|
||||||
|
|
||||||
std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.socket.sock";
|
std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.socket.sock";
|
||||||
|
|
||||||
strcpy(serverAddress.sun_path, socketPath.c_str());
|
// Use snprintf to copy the socketPath string into serverAddress.sun_path
|
||||||
|
if (snprintf(serverAddress.sun_path, sizeof(serverAddress.sun_path), "%s", socketPath.c_str()) < 0) {
|
||||||
|
spdlog::error("Hyprland IPC: Couldn't copy socket path (6)");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) {
|
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, sizeof(serverAddress)) < 0) {
|
||||||
spdlog::error("Hyprland IPC: Couldn't connect to " + socketPath + ". (3)");
|
spdlog::error("Hyprland IPC: Couldn't connect to " + socketPath + ". (3)");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue