From b7c10dcddcfbaa3dc972200d308d07784102b2b9 Mon Sep 17 00:00:00 2001 From: kidfromjupiter Date: Wed, 21 Jan 2026 15:17:41 +0000 Subject: [PATCH] Fixed bug wifi_lan server socket where ip address would be returned in dotted decimal when 4 byte string is expected --- .../implementation/linux/wifi_lan_server_socket.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/platform/implementation/linux/wifi_lan_server_socket.cc b/internal/platform/implementation/linux/wifi_lan_server_socket.cc index 3e5accff..4c10eff3 100644 --- a/internal/platform/implementation/linux/wifi_lan_server_socket.cc +++ b/internal/platform/implementation/linux/wifi_lan_server_socket.cc @@ -63,7 +63,17 @@ std::string WifiLanServerSocket::GetIPAddress() const { } if (address_data.size() > 0) { - return address_data[0]["address"]; + std::string ip_address = address_data[0]["address"]; + struct in_addr addr {}; + if (inet_aton(ip_address.c_str(), &addr) == 0) { + LOG(ERROR) << __func__ + << ": Invalid IPv4 address: " << ip_address; + return std::string(); + } + + char addr_bytes[4]; + memcpy(addr_bytes, &addr.s_addr, sizeof(addr_bytes)); + return std::string(addr_bytes, sizeof(addr_bytes)); } } }