summaryrefslogtreecommitdiffstats
path: root/lib/lz4frame.c
Commit message (Collapse)AuthorAgeFilesLines
* minor refactor : simplify LZ4F_makeBlockYann Collet2022-07-111-27/+20
| | | | one less argument
* review: fix findingsAlexander Mohr2022-07-051-1/+1
| | | | | | | | | * replace assert with test for LZ4F_uncompressedUpdate * update documentation to incldue correct docstring * remove unecessary entry point * remove compress_linked_block_mode from fuzzing test Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* uncompressed-api: allow uncompressed_update only for independent blocksAlexander Mohr2022-07-051-99/+73
| | | | Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* lz4frame: correct start and size after flushAlexander Mohr2022-07-041-1/+4
| | | | | | | | | | | when the block mode changes a flush is executed, to prevent mixing compressed and uncompressed data. Prior to this commit dstStart, dstPtr, dstCapacity where not updated to include the offset from bytesWritten. For inputs > blockSize this meant the flushed data was overwritten. Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* meson: fix meson buildAlexander Mohr2022-06-111-1/+1
| | | | add static dependency to examples
* lz4frame: fix different linkage errorAlexander Mohr2022-06-111-1/+1
| | | | Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* fuzz-test: add fuzz test for uncompressed apiAlexander Mohr2022-06-111-2/+1
| | | | | | add a fuzzing test for uncompressed frame api Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* review: Fix review findingsAlexander Mohr2022-06-101-2/+5
| | | | | | This commit fixes the review findings Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* frame-api: add method to insert uncomressed dataAlexander Mohr2022-06-091-62/+166
| | | | | | | | new method `uncompressed_update` allows to insert blocks without compression into the lz4 stream. The usage is documented in the frameCompress example Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* introduced FORWARD_IF_ERROR()Yann Collet2022-05-101-48/+49
| | | | | | and removed prefix from RETURN_ERROR(_IF) to improve brevity as it's just a local macro (no bleeding in user's namespace).
* introduced macro LZ4F_RETURN_ERROR_IFYann Collet2022-05-071-32/+23
|
* introduced macro LZ4F_RETURN_ERRORYann Collet2022-05-071-37/+39
|
* removed ERROR_GENERIC from lz4frame.hYann Collet2022-05-071-3/+3
| | | | created a new error code in the process : LZ4F_ERROR_compressionState_uninitialized
* updated one error codeYann Collet2022-04-061-1/+1
|
* Introduce MIN and MAX bounds to LZ4_MEMORY_USAGEYann Collet2022-01-311-2/+2
| | | | | | | ensure that `frametest` works fine with these values, notably with low LZ4_MEMORY_USAGE (dict test notably) following suggestions from @t-mat at #1016
* Fix typos found by codespellDimitri Papadopoulos2021-11-251-1/+1
|
* Don't reuse state memory that's too small.Eddy Jansson2021-07-311-1/+13
| | | | | | | Ensure that the memory block we're trying to reuse is large enough for the new state. Fixes #974
* fix UB lz4:988 and lz4:1178Yann Collet2021-05-281-0/+2
| | | | | ensure `dictBase` is only used when there is an actual dictionary content.
* fix UB of lz4frame:907Yann Collet2021-05-281-56/+63
| | | | | | now line 912 by ensuring pointer arithmetic is only performed if there is a reason for an internal buffer to be used.
* minor : lz4frame include stdlib only if neededYann Collet2020-11-101-1/+1
|
* LZ4F_decompress requires a valid dctx stateYann Collet2020-11-071-0/+1
| | | | | This is now explicitly documented and asserted. fix #927
* add LZ4F_decompress() tests with (NULL,0) input and outputYann Collet2020-10-021-32/+52
| | | | fix one (rare & complex) issue discovered by this test
* make scan-build accept assert()Yann Collet2020-10-011-6/+9
|
* added memcpy() related SA warning fixesYann Collet2020-10-011-8/+14
| | | | memcpy() on NULL is UB, even if length is 0.
* fix minor static analyzer warningsYann Collet2020-09-301-10/+11
| | | | | detected by scan-build and cppcheck fix #786
* fixed lz4frame with blocks of size 1Yann Collet2020-09-171-1/+4
| | | | properly track history
* Clarifies and fix EndMarkYann Collet2020-08-131-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | EndMark, the 4-bytes value indicating the end of frame, must be `0x00000000`. Previously, it was just mentioned as a `0-size` block. But such definition could encompass uncompressed blocks of size 0, with a header of value `0x80000000`. But the intention was to also support uncompressed empty blocks. They could be used as a keep-alive signal. Note that compressed empty blocks are already supported, it's just that they have a size 1 instead of 0 (for the `0` token). Unfortunately, the decoder implementation was also wrong, and would also interpret a `0x80000000` block header as an endMark. This issue evaded detection so far simply because this situation never happens, as LZ4Frame always issues a clean 0x00000000 value as a endMark. It also does not flush empty blocks. This is fixed in this PR. The decoder can now deal with empty uncompressed blocks, and do not confuse them with EndMark. The specification is also clarified. Finally, FrameTest is updated to randomly insert empty blocks during fuzzing.
* fix LZ4F_compressBound when automatic flushing is enabledChristopher Harvie2020-05-141-0/+3
|
* [lz4frame] Fix unused variable warnings in fuzzing modeNick Terrell2019-07-191-0/+9
|
* [lz4frame] Skip magic and checksums in fuzzing modeNick Terrell2019-07-191-0/+12
| | | | | When `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` is defined we skip magic and checksum checks. This makes it easier to fuzz decompression.
* fix temporary buffer use when input size hint is respectedNiko Dzhus2019-05-241-1/+1
|
* Add multiframe report to --list commandgstedman2019-05-151-2/+2
|
* Include block checksum in worst case scenario calculation of dstCapacityBrenden Eng2019-04-261-0/+1
|
* lz4frame: initializers compatibility with C++Yann Collet2019-04-191-3/+5
| | | | fix #679, reported by @degski
* ensure consistent definition and usage of FREEMEMYann Collet2019-04-161-4/+4
| | | | as suggested by @sloutsky in #671
* Merge branch 'dev' of github.com:Cyan4973/lz4 into devYann Collet2019-04-131-12/+12
|\
| * fixed minor Visual warningsYann Collet2019-04-121-12/+12
| | | | | | | | | | | | | | | | since Visual 2017, worries about potential overflow, which are actually impossible. Replaced (c * a) by (c ? a : 0). Will likely replaced a * by a cmov. Probably harmless for performance.
* | fixed incorrect assertion conditionYann Collet2019-04-131-1/+1
|/ | | | output can use the full length of output buffer
* made LZ4F_getHeaderSize() publicYann Collet2019-04-101-42/+48
|
* modified LZ4_initStreamHC() to look like LZ4_initStream()Yann Collet2019-04-091-1/+2
| | | | | it is now a pure initializer, for statically allocated states. It can initialize any memory area, and because of this, requires size.
* created LZ4_initStream()Yann Collet2019-04-051-2/+2
| | | | | | | | | | - promoted LZ4_resetStream_fast() to stable - moved LZ4_resetStream() into deprecate, but without triggering a compiler warning - update all sources to no longer rely on LZ4_resetStream() note : LZ4_initStream() proposal is slightly different : it's able to initialize any buffer, provided that it's large enough. To this end, it accepts a void*, and returns an LZ4_stream_t*.
* created LZ4_initStreamHC()Yann Collet2019-04-051-57/+69
| | | | | | | | - promoted LZ4_resetStreamHC_fast() to stable - moved LZ4_resetStreamHC() to deprecated (but do not generate a warning yet) - Updated doc, to highlight difference between init and reset - switched all invocations of LZ4_resetStreamHC() onto LZ4_initStreamHC() - misc: ensure `make all` also builds /tests
* fixed an old bug in LZ4F_flush()Yann Collet2019-04-031-47/+67
| | | | | | | which remained undetected so far, as it requires a fairly large number of conditions to be triggered, starting with enabling Block checksum, which is disabled by default, and which usage is known to be extremely rare.
* Make LZ4F_getBlockSize public and publis in experimental sectionTim Zakian2019-01-091-8/+7
|
* [amalgamation] lz4frame.cBing Xu2018-11-261-0/+7
|
* fixed #589Yann Collet2018-10-091-1/+5
| | | | | | | | following recommendations by @raggi. The fix is slightly different, but achieves the same goal, and is backed by a test tool which proves that it works (generates the error before the patch, no longer after the patch).
* added a test for LZ4F_compressEnd()Yann Collet2018-10-091-11/+14
| | | | | | | | | | | | | | | which actively tries to make it write out of bound. For this scenario to be possible, it's necessary to set dstCapacity < LZ4F_compressBound() When a compression operation fails, the CCtx context is left in an undefined state, therefore compression cannot resume. As a consequence : - round trip tests must be aborted, since there is nothing valid to decompress - most users avoid this situation, by ensuring that dstCapacity >= LZ4F_compressBound() For these reasons, this use case was poorly tested up to now.
* fixed improper hintYann Collet2018-09-281-3/+5
| | | | | | | | | | | | | when LZ4F_decompress() decodes an uncompressed block, it provides an incorrect hint for next block when frame checksum is enabled and block checksum is not. Impact is low : the hint is just an hint, the decoder works whatever the amount of input provided. But the assumption that each call to LZ4F_decompress() would generate just one complete block if input size hint was respected was broken by this error.
* fixed minor cppcheck warnings in libYann Collet2018-09-181-7/+7
|
* avoid final trailing comma for enum listsYann Collet2018-09-131-5/+5
| | | | | | | as detected in #485 by @JoachimSchneider. Refactored the c_standards tests so that these issues get automatically detected in CI tests.