mirror of
https://github.com/SabreTools/SabreTools.IO.git
synced 2026-09-22 22:56:13 +00:00
Fix Unicode string reading
This commit is contained in:
@@ -405,10 +405,10 @@ namespace SabreTools.IO.Extensions
|
||||
return null;
|
||||
|
||||
ushort size = reader.ReadUInt16();
|
||||
if (reader.BaseStream.Position + size >= reader.BaseStream.Length)
|
||||
if (reader.BaseStream.Position + (size * 2) >= reader.BaseStream.Length)
|
||||
return null;
|
||||
|
||||
byte[] buffer = reader.ReadBytes(size);
|
||||
byte[] buffer = reader.ReadBytes(size * 2);
|
||||
return Encoding.Unicode.GetString(buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -533,10 +533,10 @@ namespace SabreTools.IO.Extensions
|
||||
return null;
|
||||
|
||||
ushort size = content.ReadUInt16(ref offset);
|
||||
if (offset + size >= content.Length)
|
||||
if (offset + (size * 2) >= content.Length)
|
||||
return null;
|
||||
|
||||
byte[] buffer = content.ReadBytes(ref offset, size);
|
||||
byte[] buffer = content.ReadBytes(ref offset, size * 2);
|
||||
return Encoding.Unicode.GetString(buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -517,10 +517,10 @@ namespace SabreTools.IO.Extensions
|
||||
return null;
|
||||
|
||||
ushort size = stream.ReadUInt16();
|
||||
if (stream.Position + size >= stream.Length)
|
||||
if (stream.Position + (size * 2) >= stream.Length)
|
||||
return null;
|
||||
|
||||
byte[] buffer = stream.ReadBytes(size);
|
||||
byte[] buffer = stream.ReadBytes(size * 2);
|
||||
return Encoding.Unicode.GetString(buffer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user