From f7579fc9231e3c73d5b94e66277f49d03d243b00 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Sun, 23 Apr 2023 20:20:29 +0000 Subject: internal: unhardcode sun_path size after a6cfe7042897 (#2137) hyprctl/main.cpp:83:5: warning: 'strncpy' size argument is too large; destination buffer has size 104, but size argument is 107 [-Wfortify-source] strncpy(serverAddress.sun_path, socketPath.c_str(), 107); ^ hyprctl/main.cpp:146:5: warning: 'strncpy' size argument is too large; destination buffer has size 104, but size argument is 107 [-Wfortify-source] strncpy(serverAddress.sun_path, socketPath.c_str(), 107); ^ src/managers/EventManager.cpp:70:9: warning: 'strncpy' size argument is too large; destination buffer has size 104, but size argument is 107 [-Wfortify-source] strncpy(SERVERADDRESS.sun_path, socketPath.c_str(), 107); ^ --- src/managers/EventManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers/EventManager.cpp') diff --git a/src/managers/EventManager.cpp b/src/managers/EventManager.cpp index dd4959b8..8881b3ac 100644 --- a/src/managers/EventManager.cpp +++ b/src/managers/EventManager.cpp @@ -67,7 +67,7 @@ void CEventManager::startThread() { sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX}; std::string socketPath = "/tmp/hypr/" + g_pCompositor->m_szInstanceSignature + "/.socket2.sock"; - strncpy(SERVERADDRESS.sun_path, socketPath.c_str(), 107); + strncpy(SERVERADDRESS.sun_path, socketPath.c_str(), sizeof(SERVERADDRESS.sun_path) - 1); bind(SOCKET, (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS)); -- cgit v1.2.3