Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions SabreTools.Serialization/Readers/PKZIP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,15 @@ public class PKZIP : BaseBinaryReader<Archive>
if (extraBytes.Length != obj.ExtraFieldLength)
return null;

obj.ExtraFields = ParseExtraFields(obj, extraBytes);
}
try
{
obj.ExtraFields = ParseExtraFields(obj, extraBytes);
}
catch
{
obj.ExtraFields = null;
}
}

return obj;
}
Expand Down Expand Up @@ -778,8 +785,14 @@ public class PKZIP : BaseBinaryReader<Archive>

obj.HeaderID = (HeaderID)data.ReadUInt16LittleEndian(ref offset);
obj.DataSize = data.ReadUInt16LittleEndian(ref offset);
var readDataSize = obj.DataSize;
if (obj.DataSize >= data.Length - offset)
{
//debug goes here
readDataSize = (ushort)(data.Length - offset);
}
if (obj.DataSize > 0)
obj.Data = data.ReadBytes(ref offset, obj.DataSize);
obj.Data = data.ReadBytes(ref offset, readDataSize);

return obj;
}
Expand Down