diff options
author | Yunchih Chen <yunchih.cat@gmail.com> | 2018-03-18 12:11:04 +0800 |
---|---|---|
committer | Yunchih Chen <yunchih.cat@gmail.com> | 2018-03-18 12:11:04 +0800 |
commit | b2984ff31560ef94f8396a823f06178c0ee02d52 (patch) | |
tree | 440faa0dc41516e87b0468e84a7f2ab42e29efa8 | |
parent | 147d862098fe5c3a640dad0608d928a8edd64e9f (diff) | |
download | nfcollect-b2984ff31560ef94f8396a823f06178c0ee02d52.tar nfcollect-b2984ff31560ef94f8396a823f06178c0ee02d52.tar.gz nfcollect-b2984ff31560ef94f8396a823f06178c0ee02d52.tar.bz2 nfcollect-b2984ff31560ef94f8396a823f06178c0ee02d52.tar.lz nfcollect-b2984ff31560ef94f8396a823f06178c0ee02d52.tar.xz nfcollect-b2984ff31560ef94f8396a823f06178c0ee02d52.tar.zst nfcollect-b2984ff31560ef94f8396a823f06178c0ee02d52.zip |
Fix zstd bug
-rw-r--r-- | lib/extract.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/extract.c b/lib/extract.c index 9fd2496..dfb7223 100644 --- a/lib/extract.c +++ b/lib/extract.c @@ -33,18 +33,18 @@ static int nfl_extract_default(FILE *f, nflog_state_t *state) { static int nfl_extract_zstd(FILE *f, nflog_state_t *state) { char *buf; size_t const compressed_size = nfl_get_filesize(f) - sizeof(nflog_header_t), - estimate_decom_size = ZSTD_findDecompressedSize(state->store, compressed_size), expected_decom_size = state->header->n_entries * sizeof(nflog_entry_t); + ERR(!(buf = malloc(compressed_size)), "zstd: cannot malloc"); + fread(buf, compressed_size, 1, f); + WARN_RETURN(ferror(f), "%s", strerror(errno)); + + size_t const estimate_decom_size = ZSTD_findDecompressedSize(buf, compressed_size); if (estimate_decom_size == ZSTD_CONTENTSIZE_ERROR) FATAL("zstd: file was not compressed by zstd.\n"); else if (estimate_decom_size == ZSTD_CONTENTSIZE_UNKNOWN) FATAL("zstd: original size unknown. Use streaming decompression instead"); - ERR(!(buf = malloc(compressed_size)), "zstd: cannot malloc"); - fread(buf, compressed_size, 1, f); - WARN_RETURN(ferror(f), "%s", strerror(errno)); - size_t const actual_decom_size = ZSTD_decompress(state->store, expected_decom_size, buf, compressed_size); |