Closed ikrivosheev closed 10 months ago
Well, my research led me to this code:
if offset <= self.pos && length <= offset && self.pos + length < self.buffer.len() {
// Best case: neither source or destination wrap around
// TODO write a test for this because it used to fail
let start = self.pos - offset;
self.buffer.copy_within(start..start + length, self.pos);
@Lonami can you explain your TODO
?
I don't really remember. But if you git blame
the TODO you find commit https://github.com/Lonami/lzxd/commit/b9766e0d1cc1fc5611db543d937cd382823626dc.
So I guess that had something to do with it.
@Lonami well, continue research)
Well, I found bug.
Specification says:
R0
- Least significant to most significant byte (little-endian DWORD ([MS-DTYP]))
The key word is: DWORD
And code in the library: https://github.com/Lonami/lzxd/blob/master/src/bitstream.rs#L147
pub fn read_u32_le(&mut self) -> Result<u32, DecodeFailed> {
let lo = self.read_u16_le()? as u32;
let hi = self.read_u16_le()? as u32;
Ok((hi << 16) | lo)
}
We read as two WORDS. But we must read as DWORD. Well, I will prepare patch. And how it works in other library
@Lonami I opened PR.
After my tests - this is the last bug!
Done
@Lonami, please, publish patch release)
v0.2.4 should now be on crates.io.
I have a cab archive: python.zip
I extracted this file and have log:
gcab: gcab.txt
rust-cab ptesc.txt
Here is different: