fix: harden device model decoding

This commit is contained in:
Peter Steinberger
2025-12-20 01:48:10 +01:00
parent afa4a234f9
commit 1b38ee8b46
3 changed files with 9 additions and 6 deletions

View File

@@ -221,9 +221,10 @@ final class BridgeConnectionController {
var systemInfo = utsname()
uname(&systemInfo)
let machine = withUnsafeBytes(of: &systemInfo.machine) { ptr in
String(decoding: ptr.prefix { $0 != 0 }, as: UTF8.self)
String(bytes: ptr.prefix { $0 != 0 }, encoding: .utf8)
}
return machine.isEmpty ? "unknown" : machine
let trimmed = machine?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
return trimmed.isEmpty ? "unknown" : trimmed
}
private func appVersion() -> String {