diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-04-20 15:35:28 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-04-26 21:45:03 +0200 |
commit | acc50c92ebdaac856f29073b6b794c4a1ab40341 (patch) | |
tree | 66f8cf89ee80703044a116d87d593f57d051d4f1 /src/fuzz | |
parent | 6ed7b6977f5a7d0b1fa3c892dc600dcf4e76b05c (diff) | |
download | systemd-acc50c92ebdaac856f29073b6b794c4a1ab40341.tar.gz |
basic: move compress.[ch] → src/basic/
The compression helpers are used both in journal code and in coredump
code, and there's a good chance we'll use them later for other stuff.
Let's hence move them into src/basic/, to make them a proper internal
API we can use from everywhere where that's desirable. (pstore might be
a candidate, for example)
No real code changes, just some moving around, build system
rearrangements, and stripping of journal-def.h inclusion.
Diffstat (limited to 'src/fuzz')
-rw-r--r-- | src/fuzz/fuzz-compress.c | 21 |
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; |