internal int ProcessExtraField(Stream s, Int16 extraFieldLength)
{
int additionalBytesRead = 0;
if (extraFieldLength > 0)
{
byte[] buffer = this._Extra = new byte[extraFieldLength];
additionalBytesRead = s.Read(buffer, 0, buffer.Length);
long posn = s.Position - additionalBytesRead;
int j = 0;
while (j + 3 < buffer.Length)
{
int start = j;
UInt16 headerId = (UInt16)(buffer[j++] + buffer[j++] * 256);
Int16 dataSize = (short)(buffer[j++] + buffer[j++] * 256);
switch (headerId)
{
case 0x000a: // NTFS ctime, atime, mtime
j = ProcessExtraFieldWindowsTimes(buffer, j, dataSize, posn);
break;
case 0x5455: // Unix ctime, atime, mtime
j = ProcessExtraFieldUnixTimes(buffer, j, dataSize, posn);
break;
case 0x5855: // Info-zip Extra field (outdated)
// This is outdated, so the field is supported on
// read only.
j = ProcessExtraFieldInfoZipTimes(buffer, j, dataSize, posn);
break;
case 0x7855: // Unix uid/gid
// ignored. DotNetZip does not handle this field.
break;
case 0x7875: // ??
// ignored. I could not find documentation on this field,
// though it appears in some zip files.
break;
case 0x0001: // ZIP64
j = ProcessExtraFieldZip64(buffer, j, dataSize, posn);
break;
#if AESCRYPTO
case 0x9901: // WinZip AES encryption is in use. (workitem 6834)
// we will handle this extra field only if compressionmethod is 0x63
j = ProcessExtraFieldWinZipAes(buffer, j, dataSize, posn);
break;
#endif
case 0x0017: // workitem 7968: handle PKWare Strong encryption header
j = ProcessExtraFieldPkwareStrongEncryption(buffer, j);
break;
}
// move to the next Header in the extra field
j = start + dataSize + 4;
}
}
return additionalBytesRead;
}