Skip to content

Commit

Permalink
Merge pull request JanKallman#73 from VahidN/master
Browse files Browse the repository at this point in the history
Changed NTFS Extra Data min length to 4 in ZipEntry
  • Loading branch information
JanKallman authored Jan 25, 2018
2 parents 3757585 + 9b2a191 commit 34a195a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions EPPlus/Packaging/DotNetZip/ZipEntry.Read.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,15 +750,15 @@ private int ProcessExtraFieldWindowsTimes(byte[] buffer, int j, Int16 dataSize,
// atime 8 bytes win32 ticks since win32epoch
// ctime 8 bytes win32 ticks since win32epoch

if (dataSize != 32)
if (dataSize < 4)
throw new BadReadException(String.Format(" Unexpected size (0x{0:X4}) for NTFS times extra field at position 0x{1:X16}", dataSize, posn));

j += 4; // reserved
Int16 timetag = (Int16)(buffer[j] + buffer[j + 1] * 256);
Int16 addlsize = (Int16)(buffer[j + 2] + buffer[j + 3] * 256);
j += 4; // tag and size

if (timetag == 0x0001 && addlsize == 24)
if (timetag == 0x0001 && addlsize >= 24)
{
Int64 z = BitConverter.ToInt64(buffer, j);
this._Mtime = DateTime.FromFileTimeUtc(z);
Expand Down Expand Up @@ -790,6 +790,11 @@ private int ProcessExtraFieldWindowsTimes(byte[] buffer, int j, Int16 dataSize,
_timestamp |= ZipEntryTimestamp.Windows;
_emitNtfsTimes = true;
}
else
{
// An unknown NTFS tag so simply skip it.
j += dataSize;
}
return j;
}

Expand Down

0 comments on commit 34a195a

Please sign in to comment.