ReadShort() public method

Read a short value in little endian form from the last found data value.
public ReadShort ( ) : int
return int
Exemplo n.º 1
0
 // For AES the method in the entry is 99, and the real compression method is in the extradata
 //
 private void ProcessAESExtraData(ZipExtraData extraData)
 {
     if (extraData.Find(0x9901))
     {
         // Set version and flag for Zipfile.CreateAndInitDecryptionStream
         versionToExtract = ZipConstants.VERSION_AES;                            // Ver 5.1 = AES see "Version" getter
         // Set StrongEncryption flag for ZipFile.CreateAndInitDecryptionStream
         Flags = Flags | (int)GeneralBitFlags.StrongEncryption;
         //
         // Unpack AES extra data field see http://www.winzip.com/aes_info.htm
         int length = extraData.ValueLength;                         // Data size currently 7
         if (length < 7)
         {
             throw new ZipException("AES Extra Data Length " + length + " invalid.");
         }
         int ver            = extraData.ReadShort();                 // Version number (1=AE-1 2=AE-2)
         int vendorId       = extraData.ReadShort();                 // 2-character vendor ID 0x4541 = "AE"
         int encrStrength   = extraData.ReadByte();                  // encryption strength 1 = 128 2 = 192 3 = 256
         int actualCompress = extraData.ReadShort();                 // The actual compression method used to compress the file
         _aesVer = ver;
         _aesEncryptionStrength = encrStrength;
         method = (CompressionMethod)actualCompress;
     }
     else
     {
         throw new ZipException("AES Extra Data missing");
     }
 }
Exemplo n.º 2
0
        private void ProcessAESExtraData(ZipExtraData extraData)
        {
            if (!extraData.Find(39169))
            {
                throw new Exception("AES Extra Data missing");
            }
            this.versionToExtract = 51;
            this.Flags           |= 64;
            int valueLength = extraData.ValueLength;

            if (valueLength < 7)
            {
                throw new Exception("AES Extra Data Length " + valueLength + " invalid.");
            }
            extraData.ReadShort();
            extraData.ReadShort();
            extraData.ReadByte();
            int num = extraData.ReadShort();

            this.method = (CompressionMethod)num;
        }
Exemplo n.º 3
0
 private void ProcessAESExtraData(ZipExtraData extraData)
 {
     if (extraData.Find(39169))
     {
         versionToExtract = 51;
         Flags           |= 64;
         int valueLength = extraData.ValueLength;
         if (valueLength < 7)
         {
             throw new ZipException("AES Extra Data Length " + valueLength + " invalid.");
         }
         int aesVer = extraData.ReadShort();
         extraData.ReadShort();
         int aesEncryptionStrength = extraData.ReadByte();
         int num = extraData.ReadShort();
         _aesVer = aesVer;
         _aesEncryptionStrength = aesEncryptionStrength;
         method = (CompressionMethod)num;
         return;
     }
     throw new ZipException("AES Extra Data missing");
 }
Exemplo n.º 4
0
        private void ProcessAESExtraData(ZipExtraData extraData)
        {
            if (!extraData.Find(0x9901))
            {
                throw new ZipException("AES Extra Data missing");
            }
            this.versionToExtract = 0x33;
            this.Flags           |= 0x40;
            int valueLength = extraData.ValueLength;

            if (valueLength < 7)
            {
                throw new ZipException("AES Extra Data Length " + valueLength + " invalid.");
            }
            int num2 = extraData.ReadShort();
            int num3 = extraData.ReadShort();
            int num4 = extraData.ReadByte();
            int num5 = extraData.ReadShort();

            this._aesVer = num2;
            this._aesEncryptionStrength = num4;
            this.method = (ICSharpCode.SharpZipLib.Zip.CompressionMethod)num5;
        }
Exemplo n.º 5
0
 // For AES the method in the entry is 99, and the real compression method is in the extradata
 //
 private void ProcessAESExtraData(ZipExtraData extraData)
 {
     if (extraData.Find(0x9901)) {
         // Set version and flag for Zipfile.CreateAndInitDecryptionStream
         versionToExtract = ZipConstants.VERSION_AES;            // Ver 5.1 = AES see "Version" getter
                                                                 // Set StrongEncryption flag for ZipFile.CreateAndInitDecryptionStream
         Flags = Flags | (int)GeneralBitFlags.StrongEncryption;
         //
         // Unpack AES extra data field see http://www.winzip.com/aes_info.htm
         int length = extraData.ValueLength;         // Data size currently 7
         if (length < 7)
             throw new ZipException("AES Extra Data Length " + length + " invalid.");
         int ver = extraData.ReadShort();            // Version number (1=AE-1 2=AE-2)
         int vendorId = extraData.ReadShort();       // 2-character vendor ID 0x4541 = "AE"
         int encrStrength = extraData.ReadByte();    // encryption strength 1 = 128 2 = 192 3 = 256
         int actualCompress = extraData.ReadShort(); // The actual compression method used to compress the file
         _aesVer = ver;
         _aesEncryptionStrength = encrStrength;
         method = (CompressionMethod)actualCompress;
     } else
         throw new ZipException("AES Extra Data missing");
 }
Exemplo n.º 6
0
        /// <summary>
        /// Process extra data fields updating the entry based on the contents.
        /// </summary>
        /// <param name="localHeader">True if the extra data fields should be handled
        /// for a local header, rather than for a central header.
        /// </param>
        internal void ProcessExtraData(bool localHeader)
        {
            var extraData = new ZipExtraData(extra);

            if (extraData.Find(0x0001))
            {
                // Version required to extract is ignored here as some archivers dont set it correctly
                // in theory it should be version 45 or higher

                // The recorded size will change but remember that this is zip64.
                forceZip64_ = true;

                if (extraData.ValueLength < 4)
                {
                    throw new ZipException("Extra data extended Zip64 information length is invalid");
                }

                if (localHeader || (size == uint.MaxValue))
                {
                    size = (ulong) extraData.ReadLong();
                }

                if (localHeader || (compressedSize == uint.MaxValue))
                {
                    compressedSize = (ulong) extraData.ReadLong();
                }

                if (!localHeader && (offset == uint.MaxValue))
                {
                    offset = extraData.ReadLong();
                }

                // Disk number on which file starts is ignored
            }
            else
            {
                if (
                    ((versionToExtract & 0xff) >= ZipConstants.VersionZip64) &&
                    ((size == uint.MaxValue) || (compressedSize == uint.MaxValue))
                    )
                {
                    throw new ZipException("Zip64 Extended information required but is missing.");
                }
            }

            if (extraData.Find(10))
            {
                // No room for any tags.
                if (extraData.ValueLength < 4)
                {
                    throw new ZipException("NTFS Extra data invalid");
                }

                extraData.ReadInt(); // Reserved

                while (extraData.UnreadCount >= 4)
                {
                    int ntfsTag = extraData.ReadShort();
                    int ntfsLength = extraData.ReadShort();
                    if (ntfsTag == 1)
                    {
                        if (ntfsLength >= 24)
                        {
                            long lastModification = extraData.ReadLong();
                            long lastAccess = extraData.ReadLong();
                            long createTime = extraData.ReadLong();

                            DateTime = DateTime.FromFileTime(lastModification);
                        }
                        break;
                    }
                    else
                    {
                        // An unknown NTFS tag so simply skip it.
                        extraData.Skip(ntfsLength);
                    }
                }
            }
            else if (extraData.Find(0x5455))
            {
                int length = extraData.ValueLength;
                int flags = extraData.ReadByte();

                // Can include other times but these are ignored.  Length of data should
                // actually be 1 + 4 * no of bits in flags.
                if (((flags & 1) != 0) && (length >= 5))
                {
                    int iTime = extraData.ReadInt();

                    DateTime = (new DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime() +
                                new TimeSpan(0, 0, 0, iTime, 0)).ToLocalTime();
                }
            }
            if (method == CompressionMethod.WinZipAES)
            {
                ProcessAESExtraData(extraData);
            }
        }
Exemplo n.º 7
0
        internal void ProcessExtraData(bool localHeader)
        {
            ZipExtraData extraData = new ZipExtraData(this.extra);

            if (!extraData.Find(1))
            {
                if (((this.versionToExtract & 0xff) >= 0x2d) && ((this.size == 0xffffffffUL) || (this.compressedSize == 0xffffffffUL)))
                {
                    throw new ZipException("Zip64 Extended information required but is missing.");
                }
            }
            else
            {
                this.forceZip64_ = true;
                if (extraData.ValueLength < 4)
                {
                    throw new ZipException("Extra data extended Zip64 information length is invalid");
                }
                if (localHeader || (this.size == 0xffffffffUL))
                {
                    this.size = (ulong)extraData.ReadLong();
                }
                if (localHeader || (this.compressedSize == 0xffffffffUL))
                {
                    this.compressedSize = (ulong)extraData.ReadLong();
                }
                if (!localHeader && (this.offset == 0xffffffffUL))
                {
                    this.offset = extraData.ReadLong();
                }
            }
            if (!extraData.Find(10))
            {
                if (extraData.Find(0x5455))
                {
                    int valueLength = extraData.ValueLength;
                    if (((extraData.ReadByte() & 1) != 0) && (valueLength >= 5))
                    {
                        int seconds = extraData.ReadInt();
                        this.DateTime = (new System.DateTime(0x7b2, 1, 1, 0, 0, 0).ToUniversalTime() + new TimeSpan(0, 0, 0, seconds, 0)).ToLocalTime();
                    }
                }
            }
            else
            {
                if (extraData.ValueLength < 4)
                {
                    throw new ZipException("NTFS Extra data invalid");
                }
                extraData.ReadInt();
                while (extraData.UnreadCount >= 4)
                {
                    int amount = extraData.ReadShort();
                    if (extraData.ReadShort() == 1)
                    {
                        if (amount >= 0x18)
                        {
                            long fileTime = extraData.ReadLong();
                            extraData.ReadLong();
                            extraData.ReadLong();
                            this.DateTime = System.DateTime.FromFileTime(fileTime);
                        }
                        break;
                    }
                    extraData.Skip(amount);
                }
            }
            if (this.method == ICSharpCode.SharpZipLib.Zip.CompressionMethod.WinZipAES)
            {
                this.ProcessAESExtraData(extraData);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Process extra data fields updating the entry based on the contents.
        /// </summary>
        /// <param name="localHeader">True if the extra data fields should be handled
        /// for a local header, rather than for a central header.
        /// </param>
        internal void ProcessExtraData(bool localHeader)
        {
            ZipExtraData extraData = new ZipExtraData(this.extra);

            if (extraData.Find(0x0001))
            {
                // Version required to extract is ignored here as some archivers dont set it correctly
                // in theory it should be version 45 or higher

                // The recorded size will change but remember that this is zip64.
                forceZip64_ = true;

                if (extraData.ValueLength < 4)
                {
                    throw new ZipException("Extra data extended Zip64 information length is invalid");
                }

                if (localHeader || (size == uint.MaxValue))
                {
                    size = (ulong)extraData.ReadLong();
                }

                if (localHeader || (compressedSize == uint.MaxValue))
                {
                    compressedSize = (ulong)extraData.ReadLong();
                }

                if (!localHeader && (offset == uint.MaxValue))
                {
                    offset = extraData.ReadLong();
                }

                // Disk number on which file starts is ignored
            }
            else
            {
                if (
                    ((versionToExtract & 0xff) >= ZipConstants.VersionZip64) &&
                    ((size == uint.MaxValue) || (compressedSize == uint.MaxValue))
                    )
                {
                    throw new ZipException("Zip64 Extended information required but is missing.");
                }
            }

            if (extraData.Find(10))
            {
                // No room for any tags.
                if (extraData.ValueLength < 4)
                {
                    throw new ZipException("NTFS Extra data invalid");
                }

                extraData.ReadInt(); // Reserved

                while (extraData.UnreadCount >= 4)
                {
                    int ntfsTag    = extraData.ReadShort();
                    int ntfsLength = extraData.ReadShort();
                    if (ntfsTag == 1)
                    {
                        if (ntfsLength >= 24)
                        {
                            long lastModification = extraData.ReadLong();
                            long lastAccess       = extraData.ReadLong();
                            long createTime       = extraData.ReadLong();

                            DateTime = System.DateTime.FromFileTime(lastModification);
                        }
                        break;
                    }
                    else
                    {
                        // An unknown NTFS tag so simply skip it.
                        extraData.Skip(ntfsLength);
                    }
                }
            }
            else if (extraData.Find(0x5455))
            {
                int length = extraData.ValueLength;
                int flags  = extraData.ReadByte();

                // Can include other times but these are ignored.  Length of data should
                // actually be 1 + 4 * no of bits in flags.
                if (((flags & 1) != 0) && (length >= 5))
                {
                    int iTime = extraData.ReadInt();

                    DateTime = (new System.DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime() +
                                new TimeSpan(0, 0, 0, iTime, 0)).ToLocalTime();
                }
            }
            if (method == CompressionMethod.WinZipAES)
            {
                ProcessAESExtraData(extraData);
            }
        }
Exemplo n.º 9
0
        internal void ProcessExtraData(bool localHeader)
        {
            ZipExtraData zipExtraData = new ZipExtraData(this.extra);

            if (zipExtraData.Find(1))
            {
                this.forceZip64_ = true;
                if (zipExtraData.ValueLength < 4)
                {
                    throw new Exception("Extra data extended Zip64 information length is invalid");
                }
                if (localHeader || this.size == (ulong)-1)
                {
                    this.size = (ulong)zipExtraData.ReadLong();
                }
                if (localHeader || this.compressedSize == (ulong)-1)
                {
                    this.compressedSize = (ulong)zipExtraData.ReadLong();
                }
                if (!localHeader && this.offset == (long)((ulong)-1))
                {
                    this.offset = zipExtraData.ReadLong();
                }
            }
            else if ((this.versionToExtract & 255) >= 45 && (this.size == (ulong)-1 || this.compressedSize == (ulong)-1))
            {
                throw new Exception("Zip64 Extended information required but is missing.");
            }
            if (zipExtraData.Find(10))
            {
                if (zipExtraData.ValueLength < 4)
                {
                    throw new Exception("NTFS Extra data invalid");
                }
                zipExtraData.ReadInt();
                while (zipExtraData.UnreadCount >= 4)
                {
                    int num  = zipExtraData.ReadShort();
                    int num2 = zipExtraData.ReadShort();
                    if (num == 1)
                    {
                        if (num2 >= 24)
                        {
                            long fileTime = zipExtraData.ReadLong();
                            zipExtraData.ReadLong();
                            zipExtraData.ReadLong();
                            this.DateTime = DateTime.FromFileTime(fileTime);
                        }
                        break;
                    }
                    zipExtraData.Skip(num2);
                }
            }
            else if (zipExtraData.Find(21589))
            {
                int valueLength = zipExtraData.ValueLength;
                int num3        = zipExtraData.ReadByte();
                if ((num3 & 1) != 0 && valueLength >= 5)
                {
                    int      seconds  = zipExtraData.ReadInt();
                    DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0);
                    this.DateTime = (dateTime.ToUniversalTime() + new TimeSpan(0, 0, 0, seconds, 0)).ToLocalTime();
                }
            }
            if (this.method == CompressionMethod.WinZipAES)
            {
                this.ProcessAESExtraData(zipExtraData);
            }
        }
Exemplo n.º 10
0
        public void ReadOverrunShort()
        {
            ZipExtraData zed = new ZipExtraData(new byte[] { 1, 0, 0, 0 });
            Assert.AreEqual(4, zed.Length, "Length should be 4");
            Assert.IsTrue(zed.Find(1), "Should find tag 1");

            // Empty Tag
            bool exceptionCaught = false;
            try {
                zed.ReadShort();
            }
            catch (ZipException) {
                exceptionCaught = true;
            }
            Assert.IsTrue(exceptionCaught, "Expected EOS exception");

            // Single byte
            zed = new ZipExtraData(new byte[] { 1, 0, 1, 0, 1 });
            Assert.IsTrue(zed.Find(1), "Should find tag 1");

            exceptionCaught = false;
            try {
                zed.ReadShort();
            }
            catch (ZipException) {
                exceptionCaught = true;
            }
            Assert.IsTrue(exceptionCaught, "Expected EOS exception");

            zed = new ZipExtraData(new byte[] { 1, 0, 2, 0, 1, 2 });
            Assert.IsTrue(zed.Find(1), "Should find tag 1");

            zed.ReadShort();

            exceptionCaught = false;
            try {
                zed.ReadShort();
            }
            catch (ZipException) {
                exceptionCaught = true;
            }
            Assert.IsTrue(exceptionCaught, "Expected EOS exception");
        }
Exemplo n.º 11
0
        internal void ProcessExtraData(bool localHeader)
        {
            //IL_0171: Unknown result type (might be due to invalid IL or missing references)
            ZipExtraData zipExtraData = new ZipExtraData(extra);

            if (zipExtraData.Find(1))
            {
                forceZip64_ = true;
                if (zipExtraData.ValueLength < 4)
                {
                    throw new ZipException("Extra data extended Zip64 information length is invalid");
                }
                if (localHeader || size == 4294967295u)
                {
                    size = (ulong)zipExtraData.ReadLong();
                }
                if (localHeader || compressedSize == 4294967295u)
                {
                    compressedSize = (ulong)zipExtraData.ReadLong();
                }
                if (!localHeader && offset == 4294967295u)
                {
                    offset = zipExtraData.ReadLong();
                }
            }
            else if ((versionToExtract & 0xFF) >= 45 && (size == 4294967295u || compressedSize == 4294967295u))
            {
                throw new ZipException("Zip64 Extended information required but is missing.");
            }
            if (zipExtraData.Find(10))
            {
                if (zipExtraData.ValueLength < 4)
                {
                    throw new ZipException("NTFS Extra data invalid");
                }
                zipExtraData.ReadInt();
                while (zipExtraData.UnreadCount >= 4)
                {
                    int num  = zipExtraData.ReadShort();
                    int num2 = zipExtraData.ReadShort();
                    if (num == 1)
                    {
                        if (num2 >= 24)
                        {
                            long num3 = zipExtraData.ReadLong();
                            zipExtraData.ReadLong();
                            zipExtraData.ReadLong();
                            DateTime = global::System.DateTime.FromFileTime(num3);
                        }
                        break;
                    }
                    zipExtraData.Skip(num2);
                }
            }
            else if (zipExtraData.Find(21589))
            {
                int valueLength = zipExtraData.ValueLength;
                int num4        = zipExtraData.ReadByte();
                if (((uint)num4 & (true ? 1u : 0u)) != 0 && valueLength >= 5)
                {
                    int num5 = zipExtraData.ReadInt();
                    DateTime = (new global::System.DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime() + new TimeSpan(0, 0, 0, num5, 0)).ToLocalTime();
                }
            }
            if (method == CompressionMethod.WinZipAES)
            {
                ProcessAESExtraData(zipExtraData);
            }
        }
Exemplo n.º 12
0
        internal void ProcessExtraData(bool localHeader)
        {
            ZipExtraData data = new ZipExtraData(this.extra);

            if (data.Find(1))
            {
                if ((this.versionToExtract & 0xff) < 0x2d)
                {
                    throw new ZipException("Zip64 Extended information found but version is not valid");
                }
                this.forceZip64_ = true;
                if (data.ValueLength < 4)
                {
                    throw new ZipException("Extra data extended Zip64 information length is invalid");
                }
                if (localHeader || (this.size == 0xffffffffL))
                {
                    this.size = (ulong)data.ReadLong();
                }
                if (localHeader || (this.compressedSize == 0xffffffffL))
                {
                    this.compressedSize = (ulong)data.ReadLong();
                }
                if (!localHeader && (this.offset == 0xffffffffL))
                {
                    this.offset = data.ReadLong();
                }
            }
            else if (((this.versionToExtract & 0xff) >= 0x2d) && ((this.size == 0xffffffffL) || (this.compressedSize == 0xffffffffL)))
            {
                throw new ZipException("Zip64 Extended information required but is missing.");
            }
            if (data.Find(10))
            {
                if (data.ValueLength < 8)
                {
                    throw new ZipException("NTFS Extra data invalid");
                }
                data.ReadInt();
                while (data.UnreadCount >= 4)
                {
                    int num    = data.ReadShort();
                    int amount = data.ReadShort();
                    if (num == 1)
                    {
                        if (amount >= 0x18)
                        {
                            long fileTime = data.ReadLong();
                            data.ReadLong();
                            data.ReadLong();
                            this.DateTime = System.DateTime.FromFileTime(fileTime);
                            return;
                        }
                        return;
                    }
                    data.Skip(amount);
                }
            }
            else if (data.Find(0x5455))
            {
                int valueLength = data.ValueLength;
                if (((data.ReadByte() & 1) != 0) && (valueLength >= 5))
                {
                    int             seconds = data.ReadInt();
                    System.DateTime time    = new System.DateTime(0x7b2, 1, 1, 0, 0, 0);
                    this.DateTime = (time.ToUniversalTime() + new TimeSpan(0, 0, 0, seconds, 0)).ToLocalTime();
                }
            }
        }
Exemplo n.º 13
0
        internal void ProcessExtraData(bool localHeader)
        {
            ZipExtraData extraData = new ZipExtraData(this.extra);

            if (extraData.Find(0x0001))
            {
                if ((versionToExtract & 0xff) < ZipConstants.VersionZip64)
                {
                    throw new ZipException("Zip64 Extended information found but version is not valid");
                }

                forceZip64_ = true;

                if (extraData.ValueLength < 4)
                {
                    throw new ZipException("Extra data extended Zip64 information length is invalid");
                }

                if (localHeader || (size == uint.MaxValue))
                {
                    size = (ulong)extraData.ReadLong();
                }

                if (localHeader || (compressedSize == uint.MaxValue))
                {
                    compressedSize = (ulong)extraData.ReadLong();
                }

                if (!localHeader && (offset == uint.MaxValue))
                {
                    offset = extraData.ReadLong();
                }
            }
            else
            {
                if (
                    ((versionToExtract & 0xff) >= ZipConstants.VersionZip64) &&
                    ((size == uint.MaxValue) || (compressedSize == uint.MaxValue))
                    )
                {
                    throw new ZipException("Zip64 Extended information required but is missing.");
                }
            }

            if (extraData.Find(10))
            {
                if (extraData.ValueLength < 8)
                {
                    throw new ZipException("NTFS Extra data invalid");
                }

                extraData.ReadInt();

                while (extraData.UnreadCount >= 4)
                {
                    int ntfsTag    = extraData.ReadShort();
                    int ntfsLength = extraData.ReadShort();
                    if (ntfsTag == 1)
                    {
                        if (ntfsLength >= 24)
                        {
                            long lastModification = extraData.ReadLong();
                            long lastAccess       = extraData.ReadLong();
                            long createTime       = extraData.ReadLong();

                            DateTime = System.DateTime.FromFileTime(lastModification);
                        }
                        break;
                    }
                    else
                    {
                        extraData.Skip(ntfsLength);
                    }
                }
            }
            else if (extraData.Find(0x5455))
            {
                int length = extraData.ValueLength;
                int flags  = extraData.ReadByte();

                if (((flags & 1) != 0) && (length >= 5))
                {
                    int iTime = extraData.ReadInt();

                    DateTime = (new System.DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime() +
                                new TimeSpan(0, 0, 0, iTime, 0)).ToLocalTime();
                }
            }
        }
Exemplo n.º 14
0
 internal void ProcessExtraData(bool localHeader)
 {
     ZipExtraData extraData = new ZipExtraData(this.extra);
     if (extraData.Find(1))
     {
         this.forceZip64_ = true;
         if (extraData.ValueLength < 4)
         {
             throw new ZipException("Extra data extended Zip64 information length is invalid");
         }
         if (localHeader || (this.size == 0xffffffffL))
         {
             this.size = (ulong) extraData.ReadLong();
         }
         if (localHeader || (this.compressedSize == 0xffffffffL))
         {
             this.compressedSize = (ulong) extraData.ReadLong();
         }
         if (!localHeader && (this.offset == 0xffffffffL))
         {
             this.offset = extraData.ReadLong();
         }
     }
     else if (((this.versionToExtract & 0xff) >= 0x2d) && ((this.size == 0xffffffffL) || (this.compressedSize == 0xffffffffL)))
     {
         throw new ZipException("Zip64 Extended information required but is missing.");
     }
     if (extraData.Find(10))
     {
         if (extraData.ValueLength < 4)
         {
             throw new ZipException("NTFS Extra data invalid");
         }
         extraData.ReadInt();
         while (extraData.UnreadCount >= 4)
         {
             int num = extraData.ReadShort();
             int amount = extraData.ReadShort();
             if (num == 1)
             {
                 if (amount >= 0x18)
                 {
                     long fileTime = extraData.ReadLong();
                     extraData.ReadLong();
                     extraData.ReadLong();
                     this.DateTime = System.DateTime.FromFileTime(fileTime);
                 }
                 break;
             }
             extraData.Skip(amount);
         }
     }
     else if (extraData.Find(0x5455))
     {
         int valueLength = extraData.ValueLength;
         if (((extraData.ReadByte() & 1) != 0) && (valueLength >= 5))
         {
             int seconds = extraData.ReadInt();
             System.DateTime time = new System.DateTime(0x7b2, 1, 1, 0, 0, 0);
             this.DateTime = (time.ToUniversalTime() + new TimeSpan(0, 0, 0, seconds, 0)).ToLocalTime();
         }
     }
     if (this.method == ICSharpCode.SharpZipLib.Zip.CompressionMethod.WinZipAES)
     {
         this.ProcessAESExtraData(extraData);
     }
 }
Exemplo n.º 15
0
 private void ProcessAESExtraData(ZipExtraData extraData)
 {
     if (!extraData.Find(0x9901))
     {
         throw new ZipException("AES Extra Data missing");
     }
     this.versionToExtract = 0x33;
     this.Flags |= 0x40;
     int valueLength = extraData.ValueLength;
     if (valueLength < 7)
     {
         throw new ZipException("AES Extra Data Length " + valueLength + " invalid.");
     }
     int num2 = extraData.ReadShort();
     extraData.ReadShort();
     int num3 = extraData.ReadByte();
     int num4 = extraData.ReadShort();
     this._aesVer = num2;
     this._aesEncryptionStrength = num3;
     this.method = (ICSharpCode.SharpZipLib.Zip.CompressionMethod) num4;
 }
Exemplo n.º 16
0
        internal void ProcessExtraData(bool localHeader)
        {
            ZipExtraData extraData = new ZipExtraData(this.extra);

            if ( extraData.Find(0x0001) ) {
                if ( (versionToExtract & 0xff) < ZipConstants.VersionZip64 ) {
                    throw new ZipException("Zip64 Extended information found but version is not valid");
                }

                forceZip64_ = true;

                if ( extraData.ValueLength < 4 ) {
                    throw new ZipException("Extra data extended Zip64 information length is invalid");
                }

                if ( localHeader || (size == uint.MaxValue) ) {
                    size = (ulong)extraData.ReadLong();
                }

                if ( localHeader || (compressedSize == uint.MaxValue) ) {
                    compressedSize = (ulong)extraData.ReadLong();
                }

                if ( !localHeader && (offset == uint.MaxValue) ) {
                    offset = extraData.ReadLong();
                }
            }
            else {
                if (
                    ((versionToExtract & 0xff) >= ZipConstants.VersionZip64) &&
                    ((size == uint.MaxValue) || (compressedSize == uint.MaxValue))
                ) {
                    throw new ZipException("Zip64 Extended information required but is missing.");
                }
            }

            if ( extraData.Find(10) ) {
                if ( extraData.ValueLength < 8 ) {
                    throw new ZipException("NTFS Extra data invalid");
                }

                extraData.ReadInt();

                while ( extraData.UnreadCount >= 4 ) {
                    int ntfsTag = extraData.ReadShort();
                    int ntfsLength = extraData.ReadShort();
                    if ( ntfsTag == 1 ) {
                        if ( ntfsLength >= 24 ) {
                            long lastModification = extraData.ReadLong();
                            long lastAccess = extraData.ReadLong();
                            long createTime = extraData.ReadLong();

                            DateTime = System.DateTime.FromFileTime(lastModification);
                        }
                        break;
                    }
                    else {
                        extraData.Skip(ntfsLength);
                    }
                }
            }
            else if ( extraData.Find(0x5455) ) {
                int length = extraData.ValueLength;
                int flags = extraData.ReadByte();

                if ( ((flags & 1) != 0) && (length >= 5) ) {
                    int iTime = extraData.ReadInt();

                    DateTime = (new System.DateTime ( 1970, 1, 1, 0, 0, 0 ).ToUniversalTime() +
                        new TimeSpan ( 0, 0, 0, iTime, 0 )).ToLocalTime();
                }
            }
        }