summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Mohr <alexander.m.mohr@mercedes-benz.com>2022-06-10 06:37:57 (GMT)
committerAlexander Mohr <alexander.m.mohr@mercedes-benz.com>2022-06-10 06:37:57 (GMT)
commit5c7382798eb9b5af9eaa6c66f018c8efcb62f8d5 (patch)
tree76a0bfb048cd619191d5729e8dde6a41faa2de25
parent62f6cef564a9478b92e6dbd0faa81eaa1a90b34f (diff)
downloadlz4-5c7382798eb9b5af9eaa6c66f018c8efcb62f8d5.zip
lz4-5c7382798eb9b5af9eaa6c66f018c8efcb62f8d5.tar.gz
lz4-5c7382798eb9b5af9eaa6c66f018c8efcb62f8d5.tar.bz2
review: Fix review findings
This commit fixes the review findings Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
-rw-r--r--doc/lz4frame_manual.html47
-rw-r--r--examples/frameCompress.c1
-rw-r--r--lib/lz4frame.h33
-rw-r--r--ossfuzz/fuzz.h5
4 files changed, 47 insertions, 39 deletions
diff --git a/doc/lz4frame_manual.html b/doc/lz4frame_manual.html
index b47a92f..c55c6e9 100644
--- a/doc/lz4frame_manual.html
+++ b/doc/lz4frame_manual.html
@@ -192,32 +192,16 @@ LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx* cctx);
</p></pre><BR>
-<pre><b>size_t LZ4F_uncompressedUpdate(LZ4F_cctx* cctx,
- void* dstBuffer, size_t dstCapacity,
- const void* srcBuffer, size_t srcSize,
- const LZ4F_compressOptions_t* cOptPtr);
-/*! LZ4F_flush() :
- * When data must be generated and sent immediately, without waiting for a block to be completely filled,
- * it's possible to call LZ4_flush(). It will immediately compress any data buffered within cctx.
- * `dstCapacity` must be large enough to ensure the operation will be successful.
- * `cOptPtr` is optional : it's possible to provide NULL, all options will be set to default.
- * @return : nb of bytes written into dstBuffer (can be zero, when there is no data stored within cctx)
- * or an error code if it fails (which can be tested using LZ4F_isError())
- * Note : LZ4F_flush() is guaranteed to be successful when dstCapacity >= LZ4F_compressBound(0, prefsPtr).
- */
-size_t LZ4F_flush(LZ4F_cctx* cctx,
+<pre><b>size_t LZ4F_flush(LZ4F_cctx* cctx,
void* dstBuffer, size_t dstCapacity,
const LZ4F_compressOptions_t* cOptPtr);
-</b><p> LZ4F_uncompressedUpdate() can be called repetitively to add as much data uncompressed data as necessary.
- Important rule: dstCapacity MUST be large enough to store the entire source buffer as
- no compression is done for this operation
- If this condition is not respected, LZ4F_uncompressedUpdate() will fail (result is an errorCode).
- 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.
- `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).
+</b><p> When data must be generated and sent immediately, without waiting for a block to be completely filled,
+ it's possible to call LZ4_flush(). It will immediately compress any data buffered within cctx.
+ `dstCapacity` must be large enough to ensure the operation will be successful.
+ `cOptPtr` is optional : it's possible to provide NULL, all options will be set to default.
+ @return : nb of bytes written into dstBuffer (can be zero, when there is no data stored within cctx)
or an error code if it fails (which can be tested using LZ4F_isError())
+ Note : LZ4F_flush() is guaranteed to be successful when dstCapacity >= LZ4F_compressBound(0, prefsPtr).
</p></pre><BR>
@@ -360,6 +344,23 @@ LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx* dctx);
<pre><b>typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM)
_LZ4F_dummy_error_enum_for_c89_never_used } LZ4F_errorCodes;
</b></pre><BR>
+<pre><b>LZ4FLIB_STATIC_API size_t LZ4F_uncompressedUpdate(LZ4F_cctx* cctx,
+ void* dstBuffer, size_t dstCapacity,
+ const void* srcBuffer, size_t srcSize,
+ const LZ4F_compressOptions_t* cOptPtr);
+</b><p> LZ4F_uncompressedUpdate() can be called repetitively to add as much data uncompressed data as necessary.
+ Important rule: dstCapacity MUST be large enough to store the entire source buffer as
+ no compression is done for this operation
+ If this condition is not respected, LZ4F_uncompressedUpdate() will fail (result is an errorCode).
+ 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.
+ `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())
+
+</p></pre><BR>
+
<a name="Chapter11"></a><h2>Bulk processing dictionary API</h2><pre></pre>
<pre><b>LZ4FLIB_STATIC_API LZ4F_CDict* LZ4F_createCDict(const void* dictBuffer, size_t dictSize);
diff --git a/examples/frameCompress.c b/examples/frameCompress.c
index 3219014..25ff729 100644
--- a/examples/frameCompress.c
+++ b/examples/frameCompress.c
@@ -13,6 +13,7 @@
#include <getopt.h>
#include <lz4frame.h>
+#include <lz4frame_static.h>
#define IN_CHUNK_SIZE (16*1024)
diff --git a/lib/lz4frame.h b/lib/lz4frame.h
index 20bfb8b..7d81fa0 100644
--- a/lib/lz4frame.h
+++ b/lib/lz4frame.h
@@ -314,22 +314,6 @@ LZ4FLIB_API size_t LZ4F_compressUpdate(LZ4F_cctx* cctx,
const void* srcBuffer, size_t srcSize,
const LZ4F_compressOptions_t* cOptPtr);
-/*! LZ4F_uncompressedUpdate() :
- * LZ4F_uncompressedUpdate() can be called repetitively to add as much data uncompressed data as necessary.
- * Important rule: dstCapacity MUST be large enough to store the entire source buffer as
- * no compression is done for this operation
- * If this condition is not respected, LZ4F_uncompressedUpdate() will fail (result is an errorCode).
- * 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.
- * `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())
- */
-LZ4FLIB_API size_t LZ4F_uncompressedUpdate(LZ4F_cctx* cctx,
- void* dstBuffer, size_t dstCapacity,
- const void* srcBuffer, size_t srcSize,
- const LZ4F_compressOptions_t* cOptPtr);
/*! LZ4F_flush() :
* When data must be generated and sent immediately, without waiting for a block to be completely filled,
* it's possible to call LZ4_flush(). It will immediately compress any data buffered within cctx.
@@ -560,6 +544,23 @@ LZ4FLIB_STATIC_API LZ4F_errorCodes LZ4F_getErrorCode(size_t functionResult);
LZ4FLIB_STATIC_API size_t LZ4F_getBlockSize(unsigned);
+/*! LZ4F_uncompressedUpdate() :
+ * LZ4F_uncompressedUpdate() can be called repetitively to add as much data uncompressed data as necessary.
+ * Important rule: dstCapacity MUST be large enough to store the entire source buffer as
+ * no compression is done for this operation
+ * If this condition is not respected, LZ4F_uncompressedUpdate() will fail (result is an errorCode).
+ * 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.
+ * `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())
+ */
+LZ4FLIB_STATIC_API size_t LZ4F_uncompressedUpdate(LZ4F_cctx* cctx,
+ void* dstBuffer, size_t dstCapacity,
+ const void* srcBuffer, size_t srcSize,
+ const LZ4F_compressOptions_t* cOptPtr);
+
/**********************************
* Bulk processing dictionary API
*********************************/
diff --git a/ossfuzz/fuzz.h b/ossfuzz/fuzz.h
index eefac63..917a304 100644
--- a/ossfuzz/fuzz.h
+++ b/ossfuzz/fuzz.h
@@ -41,6 +41,11 @@ extern "C" {
int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size);
+/**
+ * Test if injection of uncompressed data into a stream is working properly
+ */
+int LLVMFuzzerUncompressedDataInjection(const uint8_t *data, size_t size)
+
#ifdef __cplusplus
}
#endif