Git Product home page Git Product logo

quicklz's People

Contributors

ariesdevil avatar flakebi avatar splamy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

quicklz's Issues

Decompress results differ from quicklz

Hello. I've been decompressing about 800 files weekly and was playing with trying to use your rust implementation of quicklz.

I altered the new() method to use a different key but everything else is the same. [that isn't involved with this, sorry]

81 of these files comes out with differing bytes. All are compressed lvl 3 and the differing bytes aren't scattered about but are in chunks (if that means anything). No errors are being returned and my rust code to call is simply...

fn decompress(data: &[u8], size: u32) -> Result<Vec<u8>, std::io::Error> {
    let mut r = std::io::Cursor::new(data.as_ref());
    match quicklz::decompress(&mut r, size) {
        Ok(r) => Ok(r),
        Err(e) => {
            eprintln!("{}", e);
            Err(std::io::Error::new(
                std::io::ErrorKind::InvalidData,
                "quicklz error",
            ))
        }
    }
}

I did notice that your implementation is not a "full" implementation but rather customized to suit your needs but I was wondering if you might have some input on this.

Attached is a sample of a file that was compressed with some embedded c++ version of quicklz. I can successfully decompress it with c++ code and python (cython) code via the pyquicklz package.

Also attached is the known 'good' decompressed file for comparison.

(renamed from .bin to .txt to attach...)
compressed.txt
decompressed.txt

hashtable scope problem

Recently I use rust to refactoring a decompress tool, and I found there might be a problem of hashtable.
In C version, the function qlz_decompress() will transmit a parameter called state_decompress, which contains the array of hashtable. That means the hashtable might be used in different compressed packages(the pointer of offset might point to decompressed datas to get value if matchlen != 0).
But in your rust implementation of quicklz, hashtable is defined only when program enter the function quicklz::decompress(). So, in the decompress progress of second and later compressed packages, the problem is more likely to cause a error, because the hashtable is empty while matchlen is not zero.
I do not know if I said clearly, and I am very happy to contact with you for more details.

ToDo: Check offset

Check here:

quicklz/src/lib.rs

Lines 189 to 204 in 35f6e71

// Check the size
if let Some(len) =
res.len().checked_add(matchlen as usize)
{
if len > dec_size {
bail!("Decompressed size exceeded");
}
} else {
bail!("Too big length in QuickLZ reference");
};
copy_buffer_bytes(
&mut res,
offset as usize,
matchlen as usize,
)?;

if offset + matchlen < dec_size and maybe also offset < vec.len()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.