fix(mac): harden gateway lock and ip decoding

This commit is contained in:
Peter Steinberger
2025-12-09 20:12:54 +00:00
parent 1a0e57d926
commit d33a3f619a
2 changed files with 28 additions and 14 deletions

View File

@@ -226,7 +226,9 @@ extension WebChatWindowController {
0,
NI_NUMERICHOST) == 0
{
let ip = String(cString: hostname)
let end = hostname.firstIndex(of: 0) ?? hostname.count
let bytes = hostname[..<end].map { UInt8(bitPattern: $0) }
let ip = String(decoding: bytes, as: UTF8.self)
if !ip.hasPrefix("169.254") { return ip }
}
}