From 9bb918f07f3829949eac61efaf6fe9c9ecf20b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sat, 29 Jan 2022 23:23:52 +0100 Subject: [PATCH] fix(data): correctly decrypt 0 length lst files --- Data/NosSmooth.Data.NOSFiles/Decryptors/LstDecryptor.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Data/NosSmooth.Data.NOSFiles/Decryptors/LstDecryptor.cs b/Data/NosSmooth.Data.NOSFiles/Decryptors/LstDecryptor.cs index 77c97bc..d81a6e6 100644 --- a/Data/NosSmooth.Data.NOSFiles/Decryptors/LstDecryptor.cs +++ b/Data/NosSmooth.Data.NOSFiles/Decryptors/LstDecryptor.cs @@ -15,8 +15,13 @@ public class LstDecryptor : IDecryptor /// public Result Decrypt(ReadOnlySpan data) { + if (data.Length == 0) + { + return Array.Empty(); + } + var output = new MemoryStream(); - int linesCount = BinaryPrimitives.ReadInt32LittleEndian(data); + var linesCount = BinaryPrimitives.ReadInt32LittleEndian(data); data = data.Slice(4); for (var i = 0; i < linesCount; i++) { -- 2.49.0