Пример #1
0
 /// <summary>
 /// Creates a new Zip input stream, for reading a zip archive.
 /// </summary>
 /// <param name="baseInputStream">The underlying <see cref="Stream"/> providing data.</param>
 public ZipInputStream(Stream baseInputStream)
     : base(baseInputStream, new Inflater(true))
 {
     internalReader = new ReadDataHandler(ReadingNotAvailable);
 }
Пример #2
0
        /// <summary>
        /// Advances to the next entry in the archive
        /// </summary>
        /// <returns>
        /// The next <see cref="ZipEntry">entry</see> in the archive or null if there are no more entries.
        /// </returns>
        /// <remarks>
        /// If the previous entry is still open <see cref="CloseEntry">CloseEntry</see> is called.
        /// </remarks>
        /// <exception cref="InvalidOperationException">
        /// Input stream is closed
        /// </exception>
        /// <exception cref="ZipException">
        /// Password is not set, password is invalid, compression method is invalid,
        /// version required to extract is not supported
        /// </exception>
        public ZipEntry GetNextEntry()
        {
            if (crc == null) {
                throw new InvalidOperationException("Closed.");
            }

            if (entry != null) {
                CloseEntry();
            }

            int header = inputBuffer.ReadLeInt();

            if (header == ZipConstants.CentralHeaderSignature ||
                header == ZipConstants.EndOfCentralDirectorySignature ||
                header == ZipConstants.CentralHeaderDigitalSignature ||
                header == ZipConstants.ArchiveExtraDataSignature ||
                header == ZipConstants.Zip64CentralFileHeaderSignature) {
                // No more individual entries exist
                Close();
                return null;
            }

            // -jr- 07-Dec-2003 Ignore spanning temporary signatures if found
            // Spanning signature is same as descriptor signature and is untested as yet.
            if ( (header == ZipConstants.SpanningTempSignature) || (header == ZipConstants.SpanningSignature) ) {
                header = inputBuffer.ReadLeInt();
            }

            if (header != ZipConstants.LocalHeaderSignature) {
                throw new ZipException("Wrong Local header signature: 0x" + String.Format("{0:X}", header));
            }

            short versionRequiredToExtract = (short)inputBuffer.ReadLeShort();

            flags          = inputBuffer.ReadLeShort();
            method         = inputBuffer.ReadLeShort();
            uint dostime   = (uint)inputBuffer.ReadLeInt();
            int crc2       = inputBuffer.ReadLeInt();
            csize          = inputBuffer.ReadLeInt();
            size           = inputBuffer.ReadLeInt();
            int nameLen    = inputBuffer.ReadLeShort();
            int extraLen   = inputBuffer.ReadLeShort();

            bool isCrypted = (flags & 1) == 1;

            byte[] buffer = new byte[nameLen];
            inputBuffer.ReadRawBuffer(buffer);

            string name = ZipConstants.ConvertToStringExt(flags, buffer);

            entry = new ZipEntry(name, versionRequiredToExtract);
            entry.Flags = flags;

            entry.CompressionMethod = (CompressionMethod)method;

            if ((flags & 8) == 0) {
                entry.Crc  = crc2 & 0xFFFFFFFFL;
                entry.Size = size & 0xFFFFFFFFL;
                entry.CompressedSize = csize & 0xFFFFFFFFL;

                entry.CryptoCheckValue = (byte)((crc2 >> 24) & 0xff);

            } else {

                // This allows for GNU, WinZip and possibly other archives, the PKZIP spec
                // says these values are zero under these circumstances.
                if (crc2 != 0) {
                    entry.Crc = crc2 & 0xFFFFFFFFL;
                }

                if (size != 0) {
                    entry.Size = size & 0xFFFFFFFFL;
                }

                if (csize != 0) {
                    entry.CompressedSize = csize & 0xFFFFFFFFL;
                }

                entry.CryptoCheckValue = (byte)((dostime >> 8) & 0xff);
            }

            entry.DosTime = dostime;

            // If local header requires Zip64 is true then the extended header should contain
            // both values.

            // Handle extra data if present.  This can set/alter some fields of the entry.
            if (extraLen > 0) {
                byte[] extra = new byte[extraLen];
                inputBuffer.ReadRawBuffer(extra);
                entry.ExtraData = extra;
            }

            entry.ProcessExtraData(true);
            if ( entry.CompressedSize >= 0 ) {
                csize = entry.CompressedSize;
            }

            if ( entry.Size >= 0 ) {
                size = entry.Size;
            }

            if (method == (int)CompressionMethod.Stored && (!isCrypted && csize != size || (isCrypted && csize - ZipConstants.CryptoHeaderSize != size))) {
                throw new ZipException("Stored, but compressed != uncompressed");
            }

            // Determine how to handle reading of data if this is attempted.
            if (entry.IsCompressionMethodSupported()) {
                internalReader = new ReadDataHandler(InitialRead);
            } else {
                internalReader = new ReadDataHandler(ReadingNotSupported);
            }

            return entry;
        }
Пример #3
0
 /// <summary>
 ///     Creates a new Zip input stream, for reading a zip archive.
 /// </summary>
 /// <param name="baseInputStream">The underlying <see cref="Stream" /> providing data.</param>
 public ZipInputStream(Stream baseInputStream)
     : base(baseInputStream, new Inflater(true))
 {
     internalReader = ReadingNotAvailable;
 }
Пример #4
0
        /// <summary>
        ///     Closes the zip input stream
        /// </summary>
        public override void Close()
        {
            internalReader = ReadingNotAvailable;
            crc = null;
            entry = null;

            base.Close();
        }
Пример #5
0
 /// <summary>
 /// Creates a new Zip input stream, for reading a zip archive.
 /// </summary>
 /// <param name="baseInputStream">The underlying <see cref="Stream"/> providing data.</param>
 public ZipInputStream(Stream baseInputStream)
     : base(baseInputStream, new Inflater(true))
 {
     this.internalReader = new ReadDataHandler(this.ReadingNotAvailable);
 }
Пример #6
0
        /// <summary>
        /// Advances to the next entry in the archive
        /// </summary>
        /// <returns>
        /// The next <see cref="ZipEntry">entry</see> in the archive or null if there are no more entries.
        /// </returns>
        /// <remarks>
        /// If the previous entry is still open <see cref="CloseEntry">CloseEntry</see> is called.
        /// </remarks>
        /// <exception cref="InvalidOperationException">
        /// Input stream is closed
        /// </exception>
        /// <exception cref="ZipException">
        /// Password is not set, password is invalid, compression method is invalid,
        /// version required to extract is not supported
        /// </exception>
        public ZipEntry GetNextEntry()
        {
            if (crc == null)
            {
                throw new InvalidOperationException("Closed.");
            }

            if (entry != null)
            {
                CloseEntry();
            }

            int header = inputBuffer.ReadLeInt();

            if (header == ZipConstants.CentralHeaderSignature ||
                header == ZipConstants.EndOfCentralDirectorySignature ||
                header == ZipConstants.CentralHeaderDigitalSignature ||
                header == ZipConstants.ArchiveExtraDataSignature ||
                header == ZipConstants.Zip64CentralFileHeaderSignature)
            {
                // No more individual entries exist
                Close();
                return(null);
            }

            // -jr- 07-Dec-2003 Ignore spanning temporary signatures if found
            // Spanning signature is same as descriptor signature and is untested as yet.
            if ((header == ZipConstants.SpanningTempSignature) || (header == ZipConstants.SpanningSignature))
            {
                header = inputBuffer.ReadLeInt();
            }

            if (header != ZipConstants.LocalHeaderSignature)
            {
                throw new ZipException("Wrong Local header signature: 0x" + String.Format("{0:X}", header));
            }

            short versionRequiredToExtract = (short)inputBuffer.ReadLeShort();

            flags  = inputBuffer.ReadLeShort();
            method = inputBuffer.ReadLeShort();
            uint dostime = (uint)inputBuffer.ReadLeInt();
            int  crc2    = inputBuffer.ReadLeInt();

            csize = inputBuffer.ReadLeInt();
            size  = inputBuffer.ReadLeInt();
            int nameLen  = inputBuffer.ReadLeShort();
            int extraLen = inputBuffer.ReadLeShort();

            bool isCrypted = (flags & 1) == 1;

            byte[] buffer = new byte[nameLen];
            inputBuffer.ReadRawBuffer(buffer);

            string name = ZipConstants.ConvertToStringExt(flags, buffer);

            entry       = new ZipEntry(name, versionRequiredToExtract);
            entry.Flags = flags;

            entry.CompressionMethod = (CompressionMethod)method;

            if ((flags & 8) == 0)
            {
                entry.Crc            = crc2 & 0xFFFFFFFFL;
                entry.Size           = size & 0xFFFFFFFFL;
                entry.CompressedSize = csize & 0xFFFFFFFFL;

                entry.CryptoCheckValue = (byte)((crc2 >> 24) & 0xff);
            }
            else
            {
                // This allows for GNU, WinZip and possibly other archives, the PKZIP spec
                // says these values are zero under these circumstances.
                if (crc2 != 0)
                {
                    entry.Crc = crc2 & 0xFFFFFFFFL;
                }

                if (size != 0)
                {
                    entry.Size = size & 0xFFFFFFFFL;
                }

                if (csize != 0)
                {
                    entry.CompressedSize = csize & 0xFFFFFFFFL;
                }

                entry.CryptoCheckValue = (byte)((dostime >> 8) & 0xff);
            }

            entry.DosTime = dostime;

            // If local header requires Zip64 is true then the extended header should contain
            // both values.

            // Handle extra data if present.  This can set/alter some fields of the entry.
            if (extraLen > 0)
            {
                byte[] extra = new byte[extraLen];
                inputBuffer.ReadRawBuffer(extra);
                entry.ExtraData = extra;
            }

            entry.ProcessExtraData(true);
            if (entry.CompressedSize >= 0)
            {
                csize = entry.CompressedSize;
            }

            if (entry.Size >= 0)
            {
                size = entry.Size;
            }

            if (method == (int)CompressionMethod.Stored && (!isCrypted && csize != size || (isCrypted && csize - ZipConstants.CryptoHeaderSize != size)))
            {
                throw new ZipException("Stored, but compressed != uncompressed");
            }

            // Determine how to handle reading of data if this is attempted.
            if (entry.IsCompressionMethodSupported())
            {
                internalReader = new ReadDataHandler(InitialRead);
            }
            else
            {
                internalReader = new ReadDataHandler(ReadingNotSupported);
            }

            return(entry);
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         internalReader = new ReadDataHandler(ReadingNotAvailable);
         crc = null;
         entry = null;
     }
     base.Dispose(disposing);
 }
Пример #8
0
 /// <summary>
 /// Creates a new Zip input stream, for reading a zip archive.
 /// </summary>
 /// <param name="baseInputStream">The underlying <see cref="Stream"/> providing data.</param>
 public ZipInputStream(Stream baseInputStream)
     : base(baseInputStream, new Inflater(true))
 {
     internalReader = ReadingNotAvailable;
 }
Пример #9
0
        public ZipEntry GetNextEntry()
        {
            if (_crc == null)
            {
                throw new InvalidOperationException("Closed.");
            }
            if (_entry != null)
            {
                CloseEntry();
            }
            var num = InputBuffer.ReadLeInt();
            switch (num)
            {
                case ZipConstants.CentralHeaderSignature:
                case ZipConstants.EndOfCentralDirectorySignature:
                case ZipConstants.CentralHeaderDigitalSignature:
                case ZipConstants.ArchiveExtraDataSignature:
                case 0x6064b50:
                    Close();
                    return null;

                case 0x30304b50:
                case ZipConstants.SpanningSignature:
                    num = InputBuffer.ReadLeInt();
                    break;
            }
            if (num != ZipConstants.LocalHeaderSignature)
            {
                throw new ZipException("Wrong Local header signature: 0x" + $"{num:X}");
            }
            var versionRequiredToExtract = (short)InputBuffer.ReadLeShort();
            _flags = InputBuffer.ReadLeShort();
            _method = InputBuffer.ReadLeShort();
            var num3 = (uint)InputBuffer.ReadLeInt();
            var num4 = InputBuffer.ReadLeInt();
            Csize = InputBuffer.ReadLeInt();
            _size = InputBuffer.ReadLeInt();
            var num5 = InputBuffer.ReadLeShort();
            var num6 = InputBuffer.ReadLeShort();
            var flag = (_flags & 1) == 1;
            var buffer = new byte[num5];
            InputBuffer.ReadRawBuffer(buffer);
            var name = ZipConstants.ConvertToStringExt(_flags, buffer);
            _entry = new ZipEntry(name, versionRequiredToExtract)
            {
                Flags = _flags,
                CompressionMethod = (CompressionMethod) _method
            };
            if ((_flags & 8) == 0)
            {
                _entry.Crc = num4 & 0xffffffffL;
                _entry.Size = _size & 0xffffffffL;
                _entry.CompressedSize = Csize & 0xffffffffL;
                _entry.CryptoCheckValue = (byte)((num4 >> 0x18) & 0xff);
            }
            else
            {
                if (num4 != 0)
                {
                    _entry.Crc = num4 & 0xffffffffL;
                }
                if (_size != 0L)
                {
                    _entry.Size = _size & 0xffffffffL;
                }
                if (Csize != 0L)
                {
                    _entry.CompressedSize = Csize & 0xffffffffL;
                }
                _entry.CryptoCheckValue = (byte)((num3 >> 8) & 0xff);
            }
            _entry.DosTime = num3;
            if (num6 > 0)
            {
                var buffer2 = new byte[num6];
                InputBuffer.ReadRawBuffer(buffer2);
                _entry.ExtraData = buffer2;
            }
            _entry.ProcessExtraData(true);
            if (_entry.CompressedSize >= 0L)
            {
                Csize = _entry.CompressedSize;
            }
            if (_entry.Size >= 0L)
            {
                _size = _entry.Size;
            }
            if ((_method == 0) && ((!flag && (Csize != _size)) || (flag && ((Csize - 12L) != _size))))
            {
                throw new ZipException("Stored, but compressed != uncompressed");
            }
            if (_entry.IsCompressionMethodSupported())
            {
                _internalReader = InitialRead;
            }
            else
            {
                _internalReader = ReadingNotSupported;
            }
            return _entry;
        }
Пример #10
0
 private int InitialRead(byte[] destination, int offset, int count)
 {
     if (!CanDecompressEntry)
     {
         throw new ZipException("Library cannot extract this entry. Version required is (" 
             + _entry.Version + ")");
     }
     if (_entry.IsCrypted)
     {
         if (_password == null)
         {
             throw new ZipException("No password set.");
         }
         var managed = new PkzipClassicManaged();
         var rgbKey = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(_password));
         InputBuffer.CryptoTransform = managed.CreateDecryptor(rgbKey, null);
         var outBuffer = new byte[12];
         InputBuffer.ReadClearTextBuffer(outBuffer, 0, 12);
         if (outBuffer[11] != _entry.CryptoCheckValue)
         {
             throw new ZipException("Invalid password");
         }
         if (Csize < 12L)
         {
             if ((_entry.Flags & 8) == 0)
             {
                 throw new ZipException($"Entry compressed size {Csize} too small for encryption");
             }
         }
         else
         {
             Csize -= 12L;
         }
     }
     else
     {
         InputBuffer.CryptoTransform = null;
     }
     if ((Csize > 0L) || ((_flags & 8) != 0))
     {
         if ((_method == 8) && (InputBuffer.Available > 0))
         {
             InputBuffer.SetInflaterInput(Inf);
         }
         _internalReader = BodyRead;
         return BodyRead(destination, offset, count);
     }
     _internalReader = ReadingNotAvailable;
     return 0;
 }
Пример #11
0
 protected override void Dispose(bool disposing) {
     if (disposing) {
         if (!disposed_) {
             internalReader=ReadingNotAvailable;
             crc=null;
             entry=null;
             disposed_=true;
         }
     }
     base.Dispose(disposing);
 }
Пример #12
0
 public ZipInputStream(Stream baseInputStream, int bufferSize) : base(baseInputStream, new Inflater(true), bufferSize)
 {
     this.crc            = new Crc32();
     this.internalReader = new ReadDataHandler(this.ReadingNotAvailable);
 }
Пример #13
0
        public ZipEntry GetNextEntry()
        {
            if (this.crc == null)
            {
                throw new InvalidOperationException("Closed.");
            }
            if (this.entry != null)
            {
                this.CloseEntry();
            }
            int num = base.inputBuffer.ReadLeInt();

            if ((num == 0x2014b50) || ((num == 0x6054b50) || ((num == 0x5054b50) || ((num == 0x7064b50) || (num == 0x6064b50)))))
            {
                this.Close();
                return(null);
            }
            if ((num == 0x30304b50) || (num == 0x8074b50))
            {
                num = base.inputBuffer.ReadLeInt();
            }
            if (num != 0x4034b50)
            {
                throw new ZipException("Wrong Local header signature: 0x" + $"{num:X}");
            }
            this.flags  = base.inputBuffer.ReadLeShort();
            this.method = base.inputBuffer.ReadLeShort();
            uint num3 = (uint)base.inputBuffer.ReadLeInt();
            int  num4 = base.inputBuffer.ReadLeInt();

            base.csize = base.inputBuffer.ReadLeInt();
            this.size  = base.inputBuffer.ReadLeInt();
            int  num5 = base.inputBuffer.ReadLeShort();
            bool flag = (this.flags & 1) == 1;

            byte[] buffer = new byte[base.inputBuffer.ReadLeShort()];
            base.inputBuffer.ReadRawBuffer(buffer);
            string name = ZipConstants.ConvertToStringExt(this.flags, buffer);

            this.entry                   = new ZipEntry(name, (short)base.inputBuffer.ReadLeShort());
            this.entry.Flags             = this.flags;
            this.entry.CompressionMethod = (CompressionMethod)this.method;
            if ((this.flags & 8) == 0)
            {
                this.entry.Crc              = num4 & 0xffffffffUL;
                this.entry.Size             = (long)(((ulong)this.size) & 0xffffffffUL);
                this.entry.CompressedSize   = (long)(((ulong)base.csize) & 0xffffffffUL);
                this.entry.CryptoCheckValue = (byte)((num4 >> 0x18) & 0xff);
            }
            else
            {
                if (num4 != 0)
                {
                    this.entry.Crc = num4 & 0xffffffffUL;
                }
                if (this.size != 0)
                {
                    this.entry.Size = (long)(((ulong)this.size) & 0xffffffffUL);
                }
                if (base.csize != 0)
                {
                    this.entry.CompressedSize = (long)(((ulong)base.csize) & 0xffffffffUL);
                }
                this.entry.CryptoCheckValue = (byte)((num3 >> 8) & 0xff);
            }
            this.entry.DosTime = num3;
            if (num5 > 0)
            {
                byte[] buffer2 = new byte[num5];
                base.inputBuffer.ReadRawBuffer(buffer2);
                this.entry.ExtraData = buffer2;
            }
            this.entry.ProcessExtraData(true);
            if (this.entry.CompressedSize >= 0L)
            {
                base.csize = this.entry.CompressedSize;
            }
            if (this.entry.Size >= 0L)
            {
                this.size = this.entry.Size;
            }
            if ((this.method == 0) && ((!flag && (base.csize != this.size)) || (flag && ((base.csize - 12) != this.size))))
            {
                throw new ZipException("Stored, but compressed != uncompressed");
            }
            this.internalReader = !this.entry.IsCompressionMethodSupported() ? new ReadDataHandler(this.ReadingNotSupported) : new ReadDataHandler(this.InitialRead);
            return(this.entry);
        }
Пример #14
0
 public ZipInputStream(Stream baseInputStream, int bufferSize)
     : base(baseInputStream, new Inflater(true), bufferSize)
 {
     _crc            = new Crc32();
     _internalReader = ReadingNotAvailable;
 }
Пример #15
0
        /// <summary>
        /// Perform the initial read on an entry which may include
        /// reading encryption headers and setting up inflation.
        /// </summary>
        /// <param name="destination">The destination to fill with data read.</param>
        /// <param name="offset">The offset to start reading at.</param>
        /// <param name="count">The maximum number of bytes to read.</param>
        /// <returns>The actual number of bytes read.</returns>
        private int InitialRead(byte[] destination, int offset, int count)
        {
            var usesDescriptor = (entry.Flags & (int)GeneralBitFlags.Descriptor) != 0;

            // Handle encryption if required.
            if (entry.IsCrypted)
            {
                if (password == null)
                {
                    throw new ZipException("No password set.");
                }

                // Generate and set crypto transform...
                var    managed = new PkzipClassicManaged();
                byte[] key     = PkzipClassic.GenerateKeys(ZipStrings.ConvertToArray(password));

                inputBuffer.CryptoTransform = managed.CreateDecryptor(key, null);

                byte[] cryptbuffer = new byte[ZipConstants.CryptoHeaderSize];
                inputBuffer.ReadClearTextBuffer(cryptbuffer, 0, ZipConstants.CryptoHeaderSize);

                if (cryptbuffer[ZipConstants.CryptoHeaderSize - 1] != entry.CryptoCheckValue)
                {
                    throw new ZipException("Invalid password");
                }

                if (csize >= ZipConstants.CryptoHeaderSize)
                {
                    csize -= ZipConstants.CryptoHeaderSize;
                }
                else if (!usesDescriptor)
                {
                    throw new ZipException($"Entry compressed size {csize} too small for encryption");
                }
            }
            else
            {
                inputBuffer.CryptoTransform = null;
            }

            if (csize > 0 || usesDescriptor)
            {
                if (method == CompressionMethod.Deflated && inputBuffer.Available > 0)
                {
                    inputBuffer.SetInflaterInput(inf);
                }

                // It's not possible to know how many bytes to read when using "Stored" compression (unless using encryption)
                if (!entry.IsCrypted && method == CompressionMethod.Stored && usesDescriptor)
                {
                    internalReader = StoredDescriptorEntry;
                    return(StoredDescriptorEntry(destination, offset, count));
                }

                if (!CanDecompressEntry)
                {
                    internalReader = ReadingNotSupported;
                    return(ReadingNotSupported(destination, offset, count));
                }

                internalReader = BodyRead;
                return(BodyRead(destination, offset, count));
            }


            internalReader = ReadingNotAvailable;
            return(0);
        }
Пример #16
0
        public ZipEntry GetNextEntry()
        {
            if (crc == null)
            {
                throw new InvalidOperationException("Closed.");
            }
            if (entry != null)
            {
                CloseEntry();
            }
            int num = inputBuffer.ReadLeInt();

            switch (num)
            {
            case 33639248:
            case 84233040:
            case 101010256:
            case 101075792:
            case 117853008:
                Dispose();
                return(null);

            case 134695760:
            case 808471376:
                num = inputBuffer.ReadLeInt();
                break;
            }
            if (num != 67324752)
            {
                throw new ZipException("Wrong Local header signature: 0x" + $"{num:X}");
            }
            short versionRequiredToExtract = (short)inputBuffer.ReadLeShort();

            flags  = inputBuffer.ReadLeShort();
            method = inputBuffer.ReadLeShort();
            uint num2 = (uint)inputBuffer.ReadLeInt();
            int  num3 = inputBuffer.ReadLeInt();

            csize = inputBuffer.ReadLeInt();
            size  = inputBuffer.ReadLeInt();
            int  num4 = inputBuffer.ReadLeShort();
            int  num5 = inputBuffer.ReadLeShort();
            bool flag = (flags & 1) == 1;

            byte[] array = new byte[num4];
            inputBuffer.ReadRawBuffer(array);
            string name = ZipConstants.ConvertToStringExt(flags, array);

            entry                   = new ZipEntry(name, versionRequiredToExtract);
            entry.Flags             = flags;
            entry.CompressionMethod = (CompressionMethod)method;
            if ((flags & 8) == 0)
            {
                entry.Crc              = (num3 & uint.MaxValue);
                entry.Size             = (size & uint.MaxValue);
                entry.CompressedSize   = (csize & uint.MaxValue);
                entry.CryptoCheckValue = (byte)((num3 >> 24) & 0xFF);
            }
            else
            {
                if (num3 != 0)
                {
                    entry.Crc = (num3 & uint.MaxValue);
                }
                if (size != 0L)
                {
                    entry.Size = (size & uint.MaxValue);
                }
                if (csize != 0L)
                {
                    entry.CompressedSize = (csize & uint.MaxValue);
                }
                entry.CryptoCheckValue = (byte)((num2 >> 8) & 0xFF);
            }
            entry.DosTime = num2;
            if (num5 > 0)
            {
                byte[] array2 = new byte[num5];
                inputBuffer.ReadRawBuffer(array2);
                entry.ExtraData = array2;
            }
            entry.ProcessExtraData(localHeader: true);
            if (entry.CompressedSize >= 0)
            {
                csize = entry.CompressedSize;
            }
            if (entry.Size >= 0)
            {
                size = entry.Size;
            }
            if (method == 0 && ((!flag && csize != size) || (flag && csize - 12 != size)))
            {
                throw new ZipException("Stored, but compressed != uncompressed");
            }
            if (entry.IsCompressionMethodSupported())
            {
                internalReader = InitialRead;
            }
            else
            {
                internalReader = ReadingNotSupported;
            }
            return(entry);
        }
Пример #17
0
 public override void Close()
 {
     this.internalReader = new ReadDataHandler(this.ReadingNotAvailable);
     this.crc = null;
     this.entry = null;
     base.Close();
 }
Пример #18
0
        /// <summary>
        /// Perform the initial read on an entry which may include
        /// reading encryption headers and setting up inflation.
        /// </summary>
        /// <param name="destination">The destination to fill with data read.</param>
        /// <param name="offset">The offset to start reading at.</param>
        /// <param name="count">The maximum number of bytes to read.</param>
        /// <returns>The actual number of bytes read.</returns>
        private int InitialRead(byte[] destination, int offset, int count)
        {
            if (!CanDecompressEntry)
            {
                throw new ZipException("Library cannot extract this entry. Version required is (" +
                                       entry.Version.ToString() + ")");
            }

            // Handle encryption if required.
            if (entry.IsCrypted)
            {
#if NETCF_1_0
                throw new ZipException("Encryption not supported for Compact Framework 1.0");
#else
                if (password == null)
                {
                    throw new ZipException("No password set.");
                }

                // Generate and set crypto transform...
                var    managed = new PkzipClassicManaged();
                byte[] key     = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(password));

                inputBuffer.CryptoTransform = managed.CreateDecryptor(key, null);

                var cryptbuffer = new byte[ZipConstants.CryptoHeaderSize];
                inputBuffer.ReadClearTextBuffer(cryptbuffer, 0, ZipConstants.CryptoHeaderSize);

                if (cryptbuffer[ZipConstants.CryptoHeaderSize - 1] != entry.CryptoCheckValue)
                {
                    throw new ZipException("Invalid password");
                }

                if (csize >= ZipConstants.CryptoHeaderSize)
                {
                    csize -= ZipConstants.CryptoHeaderSize;
                }
                else if ((entry.Flags & (int)GeneralBitFlags.Descriptor) == 0)
                {
                    throw new ZipException(string.Format("Entry compressed size {0} too small for encryption", csize));
                }
#endif
            }
            else
            {
#if !NETCF_1_0
                inputBuffer.CryptoTransform = null;
#endif
            }

            if ((csize > 0) || ((flags & (int)GeneralBitFlags.Descriptor) != 0))
            {
                if ((method == (int)CompressionMethod.Deflated) && (inputBuffer.Available > 0))
                {
                    inputBuffer.SetInflaterInput(inf);
                }

                internalReader = BodyRead;
                return(BodyRead(destination, offset, count));
            }
            else
            {
                internalReader = ReadingNotAvailable;
                return(0);
            }
        }
Пример #19
0
        public ZipEntry GetNextEntry()
        {
            if (this.crc == null)
            {
                throw new InvalidOperationException("Closed.");
            }
            if (this.entry != null)
            {
                this.CloseEntry();
            }
            int num = base.inputBuffer.ReadLeInt();
            switch (num)
            {
                case 0x2014b50:
                case 0x6054b50:
                case 0x5054b50:
                case 0x7064b50:
                case 0x6064b50:
                    this.Close();
                    return null;

                case 0x30304b50:
                case 0x8074b50:
                    num = base.inputBuffer.ReadLeInt();
                    break;
            }
            if (num != 0x4034b50)
            {
                throw new ZipException("Wrong Local header signature: 0x" + string.Format("{0:X}", num));
            }
            short versionRequiredToExtract = (short) base.inputBuffer.ReadLeShort();
            this.flags = base.inputBuffer.ReadLeShort();
            this.method = base.inputBuffer.ReadLeShort();
            uint num3 = (uint) base.inputBuffer.ReadLeInt();
            int num4 = base.inputBuffer.ReadLeInt();
            base.csize = base.inputBuffer.ReadLeInt();
            this.size = base.inputBuffer.ReadLeInt();
            int num5 = base.inputBuffer.ReadLeShort();
            int num6 = base.inputBuffer.ReadLeShort();
            bool flag = (this.flags & 1) == 1;
            byte[] buffer = new byte[num5];
            base.inputBuffer.ReadRawBuffer(buffer);
            string name = ZipConstants.ConvertToStringExt(this.flags, buffer);
            this.entry = new ZipEntry(name, versionRequiredToExtract);
            this.entry.Flags = this.flags;
            this.entry.CompressionMethod = (CompressionMethod) this.method;
            if ((this.flags & 8) == 0)
            {
                this.entry.Crc = num4 & ((long) 0xffffffffL);
                this.entry.Size = this.size & ((long) 0xffffffffL);
                this.entry.CompressedSize = base.csize & ((long) 0xffffffffL);
                this.entry.CryptoCheckValue = (byte) ((num4 >> 0x18) & 0xff);
            }
            else
            {
                if (num4 != 0)
                {
                    this.entry.Crc = num4 & ((long) 0xffffffffL);
                }
                if (this.size != 0L)
                {
                    this.entry.Size = this.size & ((long) 0xffffffffL);
                }
                if (base.csize != 0L)
                {
                    this.entry.CompressedSize = base.csize & ((long) 0xffffffffL);
                }
                this.entry.CryptoCheckValue = (byte) ((num3 >> 8) & 0xff);
            }
            this.entry.DosTime = num3;
            if (num6 > 0)
            {
                byte[] buffer2 = new byte[num6];
                base.inputBuffer.ReadRawBuffer(buffer2);
                this.entry.ExtraData = buffer2;
            }
            this.entry.ProcessExtraData(true);
            if (this.entry.CompressedSize >= 0L)
            {
                base.csize = this.entry.CompressedSize;
            }
            if (this.entry.Size >= 0L)
            {
                this.size = this.entry.Size;
            }
            if ((this.method == 0) && ((!flag && (base.csize != this.size)) || (flag && ((base.csize - 12L) != this.size))))
            {
                throw new ZipException("Stored, but compressed != uncompressed");
            }
            if (this.entry.IsCompressionMethodSupported())
            {
                this.internalReader = new ReadDataHandler(this.InitialRead);
            }
            else
            {
                this.internalReader = new ReadDataHandler(this.ReadingNotSupported);
            }
            return this.entry;
        }
Пример #20
0
 /// <summary>
 /// Creates a new Zip input stream, for reading a zip archive.
 /// </summary>
 /// <param name="baseInputStream">The underlying <see cref="Stream"/> providing data.</param>
 /// <param name="bufferSize">Size of the buffer.</param>
 public ZipInputStream(Stream baseInputStream, int bufferSize)
     : base(baseInputStream, new Inflater(true), bufferSize)
 {
     internalReader = new ReadDataHandler(ReadingNotAvailable);
 }
Пример #21
0
 public ZipInputStream(Stream baseInputStream, int bufferSize) : base(baseInputStream, new Inflater(true), bufferSize)
 {
     this.crc = new Crc32();
     this.internalReader = new ReadDataHandler(this.ReadingNotAvailable);
 }
Пример #22
0
        int InitialRead(byte[] destination, int offset, int count)
        {
            if (entry.IsCrypted) {
            #if NETCF_1_0
                throw new ZipException("Encryption not supported for Compact Framework 1.0");
            #else

                PkzipClassicManaged managed = new PkzipClassicManaged();
                byte[] key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(password));

                inputBuffer.CryptoTransform = managed.CreateDecryptor(key, null);

                byte[] cryptbuffer = new byte[ZipConstants.CryptoHeaderSize];
                inputBuffer.ReadClearTextBuffer(cryptbuffer, 0, ZipConstants.CryptoHeaderSize);

                if (csize >= ZipConstants.CryptoHeaderSize) {
                    csize -= ZipConstants.CryptoHeaderSize;
                }

            #endif
            } else {
            #if !NETCF_1_0
                inputBuffer.CryptoTransform = null;
            #endif
            }

            if ((csize > 0) || ((flags & (int)GeneralBitFlags.Descriptor) != 0)) {
                if ((method == (int)CompressionMethod.Deflated) && (inputBuffer.Available > 0)) {
                    inputBuffer.SetInflaterInput(inf);
                }

                internalReader = new ReadDataHandler(BodyRead);
                return BodyRead(destination, offset, count);
            }
            else {
                internalReader = new ReadDataHandler(ReadingNotAvailable);
                return 0;
            }
        }
Пример #23
0
 private int InitialRead(byte[] destination, int offset, int count)
 {
     if (!this.CanDecompressEntry)
     {
         throw new ZipException("Library cannot extract this entry. Version required is (" + this.entry.Version.ToString() + ")");
     }
     if (this.entry.IsCrypted)
     {
         if (this.password == null)
         {
             throw new ZipException("No password set.");
         }
         PkzipClassicManaged managed = new PkzipClassicManaged();
         byte[] rgbKey = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(this.password));
         base.inputBuffer.CryptoTransform = managed.CreateDecryptor(rgbKey, null);
         byte[] outBuffer = new byte[12];
         base.inputBuffer.ReadClearTextBuffer(outBuffer, 0, 12);
         if (outBuffer[11] != this.entry.CryptoCheckValue)
         {
             throw new ZipException("Invalid password");
         }
         if (base.csize < 12L)
         {
             if ((this.entry.Flags & 8) == 0)
             {
                 throw new ZipException(string.Format("Entry compressed size {0} too small for encryption", base.csize));
             }
         }
         else
         {
             base.csize -= 12L;
         }
     }
     else
     {
         base.inputBuffer.CryptoTransform = null;
     }
     if ((base.csize > 0L) || ((this.flags & 8) != 0))
     {
         if ((this.method == 8) && (base.inputBuffer.Available > 0))
         {
             base.inputBuffer.SetInflaterInput(base.inf);
         }
         this.internalReader = new ReadDataHandler(this.BodyRead);
         return this.BodyRead(destination, offset, count);
     }
     this.internalReader = new ReadDataHandler(this.ReadingNotAvailable);
     return 0;
 }
Пример #24
0
 /// <summary>
 ///     Creates a new Zip input stream, for reading a zip archive.
 /// </summary>
 /// <param name="baseInputStream">The underlying <see cref="Stream" /> providing data.</param>
 /// <param name="bufferSize">Size of the buffer.</param>
 public ZipInputStream(Stream baseInputStream, int bufferSize)
     : base(baseInputStream, new Inflater(true), bufferSize)
 {
     internalReader = ReadingNotAvailable;
 }
Пример #25
0
        public ZipEntry GetNextEntry()
        {
            if (crc == null)
            {
                throw new InvalidOperationException("Closed.");
            }

            if (entry != null)
            {
                CloseEntry();
            }

            int header = inputBuffer.ReadLeInt();

            if (header == ZipConstants.CentralHeaderSignature ||
                header == ZipConstants.EndOfCentralDirectorySignature ||
                header == ZipConstants.CentralHeaderDigitalSignature ||
                header == ZipConstants.ArchiveExtraDataSignature ||
                header == ZipConstants.Zip64CentralFileHeaderSignature)
            {
                Close();
                return(null);
            }


            if ((header == ZipConstants.SpanningTempSignature) || (header == ZipConstants.SpanningSignature))
            {
                header = inputBuffer.ReadLeInt();
            }

            if (header != ZipConstants.LocalHeaderSignature)
            {
                throw new ZipException("Wrong Local header signature: 0x" + String.Format("{0:X}", header));
            }

            short versionRequiredToExtract = (short)inputBuffer.ReadLeShort();

            flags  = inputBuffer.ReadLeShort();
            method = inputBuffer.ReadLeShort();
            uint dostime = (uint)inputBuffer.ReadLeInt();
            int  crc2    = inputBuffer.ReadLeInt();

            csize = inputBuffer.ReadLeInt();
            size  = inputBuffer.ReadLeInt();
            int nameLen  = inputBuffer.ReadLeShort();
            int extraLen = inputBuffer.ReadLeShort();

            bool isCrypted = (flags & 1) == 1;

            byte[] buffer = new byte[nameLen];
            inputBuffer.ReadRawBuffer(buffer);

            string name = ZipConstants.ConvertToStringExt(flags, buffer);

            entry       = new ZipEntry(name, versionRequiredToExtract);
            entry.Flags = flags;

            entry.CompressionMethod = (CompressionMethod)method;

            if ((flags & 8) == 0)
            {
                entry.Crc            = crc2 & 0xFFFFFFFFL;
                entry.Size           = size & 0xFFFFFFFFL;
                entry.CompressedSize = csize & 0xFFFFFFFFL;

                entry.CryptoCheckValue = (byte)((crc2 >> 24) & 0xff);
            }
            else
            {
                if (crc2 != 0)
                {
                    entry.Crc = crc2 & 0xFFFFFFFFL;
                }

                if (size != 0)
                {
                    entry.Size = size & 0xFFFFFFFFL;
                }

                if (csize != 0)
                {
                    entry.CompressedSize = csize & 0xFFFFFFFFL;
                }

                entry.CryptoCheckValue = (byte)((dostime >> 8) & 0xff);
            }

            entry.DosTime = dostime;

            if (extraLen > 0)
            {
                byte[] extra = new byte[extraLen];
                inputBuffer.ReadRawBuffer(extra);
                entry.ExtraData = extra;
            }

            entry.ProcessExtraData(true);
            if (entry.CompressedSize >= 0)
            {
                csize = entry.CompressedSize;
            }

            if (entry.Size >= 0)
            {
                size = entry.Size;
            }

            if (method == (int)CompressionMethod.Stored && (!isCrypted && csize != size || (isCrypted && csize - ZipConstants.CryptoHeaderSize != size)))
            {
                throw new ZipException("Stored, but compressed != uncompressed");
            }

            if (entry.IsCompressionMethodSupported())
            {
                internalReader = new ReadDataHandler(InitialRead);
            }
            else
            {
                internalReader = new ReadDataHandler(ReadingNotSupported);
            }

            return(entry);
        }
Пример #26
0
        public ZipEntry GetNextEntry()
        {
            if (crc == null) {
                throw new InvalidOperationException("Closed.");
            }

            if (entry != null) {
                CloseEntry();
            }

            int header = inputBuffer.ReadLeInt();

            if (header == ZipConstants.CentralHeaderSignature ||
                header == ZipConstants.EndOfCentralDirectorySignature ||
                header == ZipConstants.CentralHeaderDigitalSignature ||
                header == ZipConstants.ArchiveExtraDataSignature ||
                header == ZipConstants.Zip64CentralFileHeaderSignature) {

                Close();
                return null;
            }

            if ( (header == ZipConstants.SpanningTempSignature) || (header == ZipConstants.SpanningSignature) ) {
                header = inputBuffer.ReadLeInt();
            }

            if (header != ZipConstants.LocalHeaderSignature) {
                throw new ZipException("Wrong Local header signature: 0x" + String.Format("{0:X}", header));
            }

            short versionRequiredToExtract = (short)inputBuffer.ReadLeShort();

            flags          = inputBuffer.ReadLeShort();
            method         = inputBuffer.ReadLeShort();
            uint dostime   = (uint)inputBuffer.ReadLeInt();
            int crc2       = inputBuffer.ReadLeInt();
            csize          = inputBuffer.ReadLeInt();
            size           = inputBuffer.ReadLeInt();
            int nameLen    = inputBuffer.ReadLeShort();
            int extraLen   = inputBuffer.ReadLeShort();

            bool isCrypted = (flags & 1) == 1;

            byte[] buffer = new byte[nameLen];
            inputBuffer.ReadRawBuffer(buffer);

            string name = ZipConstants.ConvertToStringExt(flags, buffer);

            entry = new ZipEntry(name, versionRequiredToExtract);
            entry.Flags = flags;

            entry.CompressionMethod = (CompressionMethod)method;

            if ((flags & 8) == 0) {
                entry.Crc  = crc2 & 0xFFFFFFFFL;
                entry.Size = size & 0xFFFFFFFFL;
                entry.CompressedSize = csize & 0xFFFFFFFFL;

                entry.CryptoCheckValue = (byte)((crc2 >> 24) & 0xff);

            } else {

                if (crc2 != 0) {
                    entry.Crc = crc2 & 0xFFFFFFFFL;
                }

                if (size != 0) {
                    entry.Size = size & 0xFFFFFFFFL;
                }

                if (csize != 0) {
                    entry.CompressedSize = csize & 0xFFFFFFFFL;
                }

                entry.CryptoCheckValue = (byte)((dostime >> 8) & 0xff);
            }

            entry.DosTime = dostime;

            if (extraLen > 0) {
                byte[] extra = new byte[extraLen];
                inputBuffer.ReadRawBuffer(extra);
                entry.ExtraData = extra;
            }

            entry.ProcessExtraData(true);
            if ( entry.CompressedSize >= 0 ) {
                csize = entry.CompressedSize;
            }

            if ( entry.Size >= 0 ) {
                size = entry.Size;
            }

            if (method == (int)CompressionMethod.Stored && (!isCrypted && csize != size || (isCrypted && csize - ZipConstants.CryptoHeaderSize != size))) {
                throw new ZipException("Stored, but compressed != uncompressed");
            }

            if (entry.IsCompressionMethodSupported()) {
                internalReader = new ReadDataHandler(InitialRead);
            } else {
                internalReader = new ReadDataHandler(ReadingNotSupported);
            }

            return entry;
        }
Пример #27
0
        /// <summary>
        /// Perform the initial read on an entry which may include 
        /// reading encryption headers and setting up inflation.
        /// </summary>
        /// <param name="destination">The destination to fill with data read.</param>
        /// <param name="offset">The offset to start reading at.</param>
        /// <param name="count">The maximum number of bytes to read.</param>
        /// <returns>The actual number of bytes read.</returns>
        int InitialRead(byte[] destination, int offset, int count)
        {
            if ( !CanDecompressEntry ) {
                throw new ZipException("Library cannot extract this entry. Version required is (" + entry.Version.ToString() + ")");
            }

            // Handle encryption if required.
            if (entry.IsCrypted) {

                throw new ZipException("Encryption not supported for Compact Framework 1.0");
            } else {
            }

            if ((csize > 0) || ((flags & (int)GeneralBitFlags.Descriptor) != 0)) {
                if ((method == (int)CompressionMethod.Deflated) && (inputBuffer.Available > 0)) {
                    inputBuffer.SetInflaterInput(inf);
                }

                internalReader = new ReadDataHandler(BodyRead);
                return BodyRead(destination, offset, count);
            }
            else {
                internalReader = new ReadDataHandler(ReadingNotAvailable);
                return 0;
            }
        }
Пример #28
0
        /// <summary>
        /// Closes the zip input stream
        /// </summary>
        public override void Close()
        {
            internalReader = new ReadDataHandler(ReadingNotAvailable);
            crc = null;
            entry = null;

            base.Close();
        }
Пример #29
0
 public ZipInputStream(Stream baseInputStream, int bufferSize)
     : base(baseInputStream, new Inflater(noHeader: true), bufferSize)
 {
     internalReader = ReadingNotAvailable;
 }
Пример #30
0
        /// <summary>
        /// Perform the initial read on an entry which may include 
        /// reading encryption headers and setting up inflation.
        /// </summary>
        /// <param name="destination">The destination to fill with data read.</param>
        /// <param name="offset">The offset to start reading at.</param>
        /// <param name="count">The maximum number of bytes to read.</param>
        /// <returns>The actual number of bytes read.</returns>
        int InitialRead(byte[] destination, int offset, int count)
        {
            if ( !CanDecompressEntry ) {
                throw new ZipException("Library cannot extract this entry. Version required is (" + entry.Version.ToString() + ")");
            }

            // Handle encryption if required.
            if (entry.IsCrypted) {
            #if NETCF_1_0
                throw new ZipException("Encryption not supported for Compact Framework 1.0");
            #else
                if (password == null) {
                    throw new ZipException("No password set.");
                }

                // Generate and set crypto transform...
                PkzipClassicManaged managed = new PkzipClassicManaged();
                byte[] key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(password));

                inputBuffer.CryptoTransform = managed.CreateDecryptor(key, null);

                byte[] cryptbuffer = new byte[ZipConstants.CryptoHeaderSize];
                inputBuffer.ReadClearTextBuffer(cryptbuffer, 0, ZipConstants.CryptoHeaderSize);

                if (cryptbuffer[ZipConstants.CryptoHeaderSize - 1] != entry.CryptoCheckValue) {
                    throw new ZipException("Invalid password");
                }

                if (csize >= ZipConstants.CryptoHeaderSize) {
                    csize -= ZipConstants.CryptoHeaderSize;
                }
                else if ( (entry.Flags & (int)GeneralBitFlags.Descriptor) == 0 ) {
                    throw new ZipException(string.Format("Entry compressed size {0} too small for encryption", csize));
                }
            #endif
            } else {
            #if !NETCF_1_0
                inputBuffer.CryptoTransform = null;
            #endif
            }

            if ((csize > 0) || ((flags & (int)GeneralBitFlags.Descriptor) != 0)) {
                if ((method == (int)CompressionMethod.Deflated) && (inputBuffer.Available > 0)) {
                    inputBuffer.SetInflaterInput(inf);
                }

                internalReader = new ReadDataHandler(BodyRead);
                return BodyRead(destination, offset, count);
            }
            else {
                internalReader = new ReadDataHandler(ReadingNotAvailable);
                return 0;
            }
        }
Пример #31
0
        public ZipEntry GetNextEntry()
        {
            if (_crc == null)
            {
                throw new InvalidOperationException("Closed.");
            }
            if (_entry != null)
            {
                CloseEntry();
            }
            var num = InputBuffer.ReadLeInt();

            switch (num)
            {
            case ZipConstants.CentralHeaderSignature:
            case ZipConstants.EndOfCentralDirectorySignature:
            case ZipConstants.CentralHeaderDigitalSignature:
            case ZipConstants.ArchiveExtraDataSignature:
            case 0x6064b50:
                Close();
                return(null);

            case 0x30304b50:
            case ZipConstants.SpanningSignature:
                num = InputBuffer.ReadLeInt();
                break;
            }
            if (num != ZipConstants.LocalHeaderSignature)
            {
                throw new ZipException("Wrong Local header signature: 0x" + $"{num:X}");
            }
            var versionRequiredToExtract = (short)InputBuffer.ReadLeShort();

            _flags  = InputBuffer.ReadLeShort();
            _method = InputBuffer.ReadLeShort();
            var num3 = (uint)InputBuffer.ReadLeInt();
            var num4 = InputBuffer.ReadLeInt();

            Csize = InputBuffer.ReadLeInt();
            _size = InputBuffer.ReadLeInt();
            var num5   = InputBuffer.ReadLeShort();
            var num6   = InputBuffer.ReadLeShort();
            var flag   = (_flags & 1) == 1;
            var buffer = new byte[num5];

            InputBuffer.ReadRawBuffer(buffer);
            var name = ZipConstants.ConvertToStringExt(_flags, buffer);

            _entry = new ZipEntry(name, versionRequiredToExtract)
            {
                Flags             = _flags,
                CompressionMethod = (CompressionMethod)_method
            };
            if ((_flags & 8) == 0)
            {
                _entry.Crc              = num4 & 0xffffffffL;
                _entry.Size             = _size & 0xffffffffL;
                _entry.CompressedSize   = Csize & 0xffffffffL;
                _entry.CryptoCheckValue = (byte)((num4 >> 0x18) & 0xff);
            }
            else
            {
                if (num4 != 0)
                {
                    _entry.Crc = num4 & 0xffffffffL;
                }
                if (_size != 0L)
                {
                    _entry.Size = _size & 0xffffffffL;
                }
                if (Csize != 0L)
                {
                    _entry.CompressedSize = Csize & 0xffffffffL;
                }
                _entry.CryptoCheckValue = (byte)((num3 >> 8) & 0xff);
            }
            _entry.DosTime = num3;
            if (num6 > 0)
            {
                var buffer2 = new byte[num6];
                InputBuffer.ReadRawBuffer(buffer2);
                _entry.ExtraData = buffer2;
            }
            _entry.ProcessExtraData(true);
            if (_entry.CompressedSize >= 0L)
            {
                Csize = _entry.CompressedSize;
            }
            if (_entry.Size >= 0L)
            {
                _size = _entry.Size;
            }
            if ((_method == 0) && ((!flag && (Csize != _size)) || (flag && ((Csize - 12L) != _size))))
            {
                throw new ZipException("Stored, but compressed != uncompressed");
            }
            if (_entry.IsCompressionMethodSupported())
            {
                _internalReader = InitialRead;
            }
            else
            {
                _internalReader = ReadingNotSupported;
            }
            return(_entry);
        }