From 385726e701257574aa4c64b4b29ec87a9b07816f Mon Sep 17 00:00:00 2001 From: "Soc Virnyl S. Estela" Date: Fri, 2 Dec 2022 21:36:14 +0800 Subject: [PATCH 1/3] fix: use getaddrinfo() instead of gethostbyname() --- src/modules/hyprland/backend.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/hyprland/backend.cpp b/src/modules/hyprland/backend.cpp index 76c071c..0c82aba 100644 --- a/src/modules/hyprland/backend.cpp +++ b/src/modules/hyprland/backend.cpp @@ -130,6 +130,8 @@ void IPC::unregisterForIPC(EventHandler* ev_handler) { callbackMutex.unlock(); } + + std::string IPC::getSocket1Reply(const std::string& rq) { // basically hyprctl @@ -140,7 +142,7 @@ std::string IPC::getSocket1Reply(const std::string& rq) { return ""; } - const auto SERVER = gethostbyname("localhost"); + const auto SERVER = getaddrinfo("localhost", NULL, NULL, 0); if (!SERVER) { spdlog::error("Hyprland IPC: Couldn't get host (2)"); From 0540977e45bf677ffcd6b33f25e7e88655f02ec5 Mon Sep 17 00:00:00 2001 From: "Soc Virnyl S. Estela" Date: Fri, 2 Dec 2022 21:42:58 +0800 Subject: [PATCH 2/3] format: remove some newlines --- src/modules/hyprland/backend.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/modules/hyprland/backend.cpp b/src/modules/hyprland/backend.cpp index 0c82aba..f110825 100644 --- a/src/modules/hyprland/backend.cpp +++ b/src/modules/hyprland/backend.cpp @@ -130,8 +130,6 @@ void IPC::unregisterForIPC(EventHandler* ev_handler) { callbackMutex.unlock(); } - - std::string IPC::getSocket1Reply(const std::string& rq) { // basically hyprctl From 55d7868f86b3ebb22116e0889fba60b4cdff3f4a Mon Sep 17 00:00:00 2001 From: "Soc Virnyl S. Estela" Date: Fri, 2 Dec 2022 22:18:32 +0800 Subject: [PATCH 3/3] fix(2): use getaddrinfo() instead of gethostbyname() --- src/modules/hyprland/backend.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/hyprland/backend.cpp b/src/modules/hyprland/backend.cpp index f110825..33212c7 100644 --- a/src/modules/hyprland/backend.cpp +++ b/src/modules/hyprland/backend.cpp @@ -132,15 +132,20 @@ void IPC::unregisterForIPC(EventHandler* ev_handler) { std::string IPC::getSocket1Reply(const std::string& rq) { // basically hyprctl - + + struct addrinfo ai_hints; + struct addrinfo *ai_res = NULL; const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0); if (SERVERSOCKET < 0) { spdlog::error("Hyprland IPC: Couldn't open a socket (1)"); return ""; } - - const auto SERVER = getaddrinfo("localhost", NULL, NULL, 0); + + memset(&ai_hints, 0, sizeof(struct addrinfo)); + ai_hints.ai_family = AF_UNSPEC; + ai_hints.ai_socktype = SOCK_STREAM; + const auto SERVER = getaddrinfo("localhost", NULL, &ai_hints, &ai_res); if (!SERVER) { spdlog::error("Hyprland IPC: Couldn't get host (2)");