hylander0/Iteedee.ApkReader

Sometimes the resource file cannot be extracted correctly by sharpzip

Closed this issue · 1 comments

kkguo commented

Due to bug in sharpzip, when the apk zipped as deflater mode, the zipinputstream.length is not set until you read the stream out. your example sometimes is not working.

using (Stream strm = zipfile.GetInputStream(item))
{
         using (BinaryReader s = new BinaryReader(strm))
         {
                resourcesData = s.ReadBytes((int)s.BaseStream.Length);

            }
}

solution is using entry.size instead of s.BaseStream.Length

using (Stream strm = zipfile.GetInputStream(item))
{
          using (BinaryReader s = new BinaryReader(strm))
           {
                resourcesData = s.ReadBytes((int)item.size);

           }
 }
kkguo commented

if you are using sharpzip, use the entry size instead of stream length.