summaryrefslogtreecommitdiff
path: root/src/fuzz
diff options
context:
space:
mode:
Diffstat (limited to 'src/fuzz')
-rw-r--r--src/fuzz/fuzz-compress.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/fuzz/fuzz-compress.c b/src/fuzz/fuzz-compress.c
index 189bd210b5..4c1186c83b 100644
--- a/src/fuzz/fuzz-compress.c
+++ b/src/fuzz/fuzz-compress.c
@@ -6,21 +6,10 @@
#include "compress.h"
#include "fuzz.h"
-static int compress(int alg,
- const void *src, uint64_t src_size,
- void *dst, size_t dst_alloc_size, size_t *dst_size) {
-
- if (alg == OBJECT_COMPRESSED_LZ4)
- return compress_blob_lz4(src, src_size, dst, dst_alloc_size, dst_size);
- if (alg == OBJECT_COMPRESSED_XZ)
- return compress_blob_xz(src, src_size, dst, dst_alloc_size, dst_size);
- return -EOPNOTSUPP;
-}
-
typedef struct header {
- uint32_t alg:2; /* We have only two compression algorithms so far, but we might add
- * more in the future. Let's make this a bit wider so our fuzzer
- * cases remain stable in the future. */
+ uint32_t alg:2; /* We have only three compression algorithms so far, but we might add more in the
+ * future. Let's make this a bit wider so our fuzzer cases remain stable in the
+ * future. */
uint32_t sw_len;
uint32_t sw_alloc;
uint32_t reserved[3]; /* Extra space to keep fuzz cases stable in case we need to
@@ -46,7 +35,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
log_set_max_level(LOG_CRIT);
log_info("Using compression %s, data size=%zu",
- object_compressed_to_string(alg) ?: "(none)",
+ compression_to_string(alg) ?: "(none)",
data_len);
buf = malloc(MAX(size, 128u)); /* Make the buffer a bit larger for very small data */
@@ -56,7 +45,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
size_t csize;
- r = compress(alg, h->data, data_len, buf, size, &csize);
+ r = compress_blob_explicit(alg, h->data, data_len, buf, size, &csize);
if (r < 0) {
log_error_errno(r, "Compression failed: %m");
return 0;