Skip to content

Commit

Permalink
fix 10XGenomics#14 - allow 0 sized uncompressed data
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarks committed Mar 5, 2022
1 parent 0a1d269 commit 3138ba7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lz4-sys/liblz4
Submodule liblz4 updated 94 files
+0 −5 .cirrus.yml
+0 −32 .github/ISSUE_TEMPLATE/bug_report.md
+0 −20 .github/ISSUE_TEMPLATE/feature_request.md
+0 −3 .gitignore
+9 −25 .travis.yml
+5 −10 Makefile
+0 −36 NEWS
+12 −11 README.md
+15 −21 appveyor.yml
+0 −16 build/.gitignore
+0 −51 build/VS2017/lz4/lz4.rc
+0 −164 build/VS2017/lz4/lz4.vcxproj
+0 −0 contrib/cmake_unofficial/.gitignore
+6 −13 contrib/cmake_unofficial/CMakeLists.txt
+2 −2 contrib/debian/copyright
+2 −1 contrib/debian/rules
+3 −2 contrib/gen_manual/gen_manual.cpp
+0 −0 contrib/meson/GetLz4LibraryVersion.py
+0 −0 contrib/meson/InstallSymlink.py
+1 −1 contrib/meson/contrib/gen_manual/meson.build
+0 −0 contrib/meson/contrib/meson.build
+1 −1 contrib/meson/examples/meson.build
+1 −1 contrib/meson/lib/meson.build
+109 −5 contrib/meson/meson.build
+0 −117 contrib/meson/meson/meson.build
+1 −1 contrib/meson/programs/meson.build
+1 −1 contrib/meson/tests/meson.build
+19 −30 doc/lz4_Frame_format.md
+46 −83 doc/lz4_manual.html
+5 −7 doc/lz4frame_manual.html
+1 −1 examples/Makefile
+2 −2 examples/frameCompress.c
+6 −6 examples/streaming_api_basics.md
+1 −1 lib/Makefile
+10 −27 lib/README.md
+230 −327 lib/lz4.c
+70 −80 lib/lz4.h
+54 −93 lib/lz4frame.c
+14 −22 lib/lz4frame.h
+115 −192 lib/lz4hc.c
+40 −15 lib/lz4hc.h
+8 −12 ossfuzz/Makefile
+5 −11 ossfuzz/compress_frame_fuzzer.c
+2 −9 ossfuzz/compress_fuzzer.c
+3 −10 ossfuzz/compress_hc_fuzzer.c
+3 −11 ossfuzz/decompress_frame_fuzzer.c
+2 −6 ossfuzz/decompress_fuzzer.c
+0 −77 ossfuzz/fuzz_data_producer.c
+0 −36 ossfuzz/fuzz_data_producer.h
+4 −8 ossfuzz/round_trip_frame_fuzzer.c
+2 −9 ossfuzz/round_trip_fuzzer.c
+2 −7 ossfuzz/round_trip_hc_fuzzer.c
+1 −6 ossfuzz/travisoss.sh
+0 −1 programs/.gitignore
+7 −21 programs/Makefile
+43 −233 programs/bench.c
+1 −2 programs/bench.h
+18 −32 programs/lz4cli.c
+248 −316 programs/lz4io.c
+9 −9 programs/lz4io.h
+5 −6 programs/platform.h
+22 −74 programs/util.h
+0 −1 tests/.gitignore
+85 −150 tests/Makefile
+9 −1 tests/checkFrame.c
+0 −49 tests/decompress-partial.c
+24 −60 tests/frametest.c
+15 −64 tests/fullbench.c
+60 −243 tests/fuzzer.c
+0 −8 tests/test_install.sh
+ tmp
+ tmpsparse
+10 −0 visual/.gitignore
+8 −10 visual/README.md
+0 −0 visual/VS2010/datagen/datagen.vcxproj
+0 −0 visual/VS2010/frametest/frametest.vcxproj
+0 −0 visual/VS2010/fullbench-dll/fullbench-dll.vcxproj
+0 −0 visual/VS2010/fullbench/fullbench.vcxproj
+0 −0 visual/VS2010/fuzzer/fuzzer.vcxproj
+0 −0 visual/VS2010/liblz4-dll/liblz4-dll.rc
+0 −0 visual/VS2010/liblz4-dll/liblz4-dll.vcxproj
+0 −0 visual/VS2010/liblz4/liblz4.vcxproj
+0 −0 visual/VS2010/lz4.sln
+0 −0 visual/VS2010/lz4/lz4.rc
+0 −0 visual/VS2010/lz4/lz4.vcxproj
+0 −0 visual/VS2017/datagen/datagen.vcxproj
+0 −0 visual/VS2017/frametest/frametest.vcxproj
+0 −0 visual/VS2017/fullbench-dll/fullbench-dll.vcxproj
+0 −0 visual/VS2017/fullbench/fullbench.vcxproj
+0 −0 visual/VS2017/fuzzer/fuzzer.vcxproj
+0 −0 visual/VS2017/liblz4-dll/liblz4-dll.rc
+0 −0 visual/VS2017/liblz4-dll/liblz4-dll.vcxproj
+0 −0 visual/VS2017/liblz4/liblz4.vcxproj
+0 −10 visual/VS2017/lz4.sln
11 changes: 10 additions & 1 deletion src/block/mod.rs
Expand Up @@ -141,7 +141,7 @@ pub fn decompress(mut src: &[u8], uncompressed_size: Option<i32>) -> Result<Vec<
src = &src[4..];
}

if size <= 0 {
if size < 0 {
return Err(Error::new(
ErrorKind::InvalidInput,
if uncompressed_size.is_some() {
Expand Down Expand Up @@ -276,4 +276,13 @@ mod test {

assert_eq!(decompress(&compressed, None).unwrap(), reference.as_bytes())
}

#[test]
fn test_empty_compress() {
use crate::block::{compress, decompress};
let v = vec![0u8; 0];
let comp_with_prefix = compress(&v, None, true).unwrap();
dbg!(&comp_with_prefix);
assert_eq!(v, decompress(&comp_with_prefix, None).unwrap());
}
}

0 comments on commit 3138ba7

Please sign in to comment.