Strip null-terminator

This commit is contained in:
Bond_009
2026-06-16 17:54:23 +02:00
parent 4c228eaf63
commit e86b502cbc

View File

@@ -37,7 +37,12 @@ public static partial class ApplePlatformHelper
throw new NotSupportedException($"Failed to get sysctl value for {name} with error {osStatus}");
}
ReadOnlySpan<byte> data = buffer.AsSpan()[..(int)length];
if (length < 1)
{
return string.Empty;
}
ReadOnlySpan<byte> data = buffer.AsSpan()[..(int)(length - 1)];
return Encoding.UTF8.GetString(data);
}
finally