You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for (var i = 0; i < bytesToAdvance / skipBuffer.Length; i++)
{
rawStream.Read(skipBuffer, 0, skipBuffer.Length);
}
rawStream.Read(skipBuffer, 0, (int)(bytesToAdvance % skipBuffer.Length));
this code assume rawStream.Read always read until requested count.
but if you test with remote stream (from network like ftp), MoveToNextEntry() throw Unknown header exception. because skip function do not actually skip.
i fixed code like this, and it works fine for me.
var bytesToAdvance = Entry.CompressedSize;
int readBytes = 0;
while (bytesToAdvance > 0)
{
if (bytesToAdvance >= skipBuffer.Length)
readBytes = rawStream.Read(skipBuffer, 0, skipBuffer.Length);
else
readBytes = rawStream.Read(skipBuffer, 0, (int)bytesToAdvance);
bytesToAdvance -= readBytes;
if (readBytes == 0 && bytesToAdvance > 0)
throw new Exception("skip failed");
}
return;
}
please let me know if it is not a bug.
The text was updated successfully, but these errors were encountered:
You're probably correct in that I have some bad skip code. I've noticed recently there are several different implementations of this kind of thing in the codebase. I need to consolidate this at the very least.
I have Skip/Transfer code in Utility.cs that probably should be used instead and does what you're referring to.
I likely won't get time for a while to fix this but pull requests are welcome :)
adamhathcock
changed the title
I think AbstractReader.Skip() has a bug.
AbstractReader.Skip() does not fully read bytes from non-local streams
Jul 14, 2017
for (var i = 0; i < bytesToAdvance / skipBuffer.Length; i++)
{
rawStream.Read(skipBuffer, 0, skipBuffer.Length);
}
rawStream.Read(skipBuffer, 0, (int)(bytesToAdvance % skipBuffer.Length));
this code assume rawStream.Read always read until requested count.
but if you test with remote stream (from network like ftp), MoveToNextEntry() throw Unknown header exception. because skip function do not actually skip.
i fixed code like this, and it works fine for me.
please let me know if it is not a bug.
The text was updated successfully, but these errors were encountered: