Skip to content

Commit

Permalink
review: fix findings
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
alexmohr committed Jul 5, 2022
1 parent 42eb47d commit ab8c4ee
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 22 deletions.
2 changes: 1 addition & 1 deletion contrib/meson/meson/examples/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ foreach e, src : examples
executable(
e,
lz4_source_root / 'examples' / src,
dependencies: [liblz4_dep, liblz4_internal_dep],
dependencies: [liblz4_internal_dep],
install: false
)
endforeach
1 change: 1 addition & 0 deletions doc/lz4frame_manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ <h1>1.9.4 Manual</h1>
After an error, the state is left in a UB state, and must be re-initialized or freed.
If previously a compressed block was written, buffered data is flushed
before appending uncompressed data is continued.
This is only supported when LZ4F_blockIndependent is used
`cOptPtr` is optional : NULL can be provided, in which case all options are set to default.
@return : number of bytes written into `dstBuffer` (it can be zero, meaning input data was just buffered).
or an error code if it fails (which can be tested using LZ4F_isError())
Expand Down
2 changes: 1 addition & 1 deletion lib/lz4frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ size_t LZ4F_uncompressedUpdate(LZ4F_cctx* cctxPtr,
void* dstBuffer, size_t dstCapacity,
const void* srcBuffer, size_t srcSize,
const LZ4F_compressOptions_t* compressOptionsPtr) {
assert(cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockIndependent);
RETURN_ERROR_IF(cctxPtr->prefs.frameInfo.blockMode != LZ4F_blockIndependent, blockMode_invalid);
return LZ4F_compressUpdateImpl(cctxPtr,
dstBuffer, dstCapacity,
srcBuffer, srcSize,
Expand Down
12 changes: 0 additions & 12 deletions lib/lz4hc.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,18 +405,6 @@ LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary(
LZ4_streamHC_t *working_stream,
const LZ4_streamHC_t *dictionary_stream);

/*! LZ4_getDictHCSize():
* Get the size of the dictionary. This can be used for adding data without
* compression to the LZ4 archive. If linked blocked mode is used the memory
* of the dictionary is kept free.
* This way uncompressed data does not influence the effectiveness of the
* dictionary.
* @param LZ4_dict Pointer to the dictionary to get the size of.
* @param dictSize The maximum dictionary size. (Normally 64 KB).
* @return The size of the dictionary.
*/
LZ4LIB_STATIC_API int LZ4_getDictHCSize(const LZ4_streamHC_t* LZ4_streamHCPtr, int dictSize);

#if defined (__cplusplus)
}
#endif
Expand Down
8 changes: 0 additions & 8 deletions ossfuzz/round_trip_frame_uncompressed_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,6 @@ static void compress_round_trip(const uint8_t* data, size_t size,
LZ4F_freeCompressionContext(ctx);
}

static void compress_linked_block_mode(const uint8_t* data, size_t size) {
FUZZ_dataProducer_t *producer = FUZZ_dataProducer_create(data, size);
LZ4F_preferences_t prefs = FUZZ_dataProducer_preferences(producer);
prefs.frameInfo.blockMode = LZ4F_blockLinked;
compress_round_trip(data, size, producer, prefs);
}

static void compress_independent_block_mode(const uint8_t* data, size_t size) {
FUZZ_dataProducer_t *producer = FUZZ_dataProducer_create(data, size);
LZ4F_preferences_t prefs = FUZZ_dataProducer_preferences(producer);
Expand All @@ -140,7 +133,6 @@ static void compress_independent_block_mode(const uint8_t* data, size_t size) {


int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
compress_linked_block_mode(data, size);
compress_independent_block_mode(data, size);
return 0;
}

0 comments on commit ab8c4ee

Please sign in to comment.