diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-16 02:11:29 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-16 02:11:29 +0200 |
| commit | 8e7bfadb3eb9f43eb0b670b908b479325722fee5 (patch) | |
| tree | e7f26f67cc4da2846e0ac3f8201e1e82de3c6112 /librecrypt_encode.c | |
| parent | m (diff) | |
| download | librecrypt-8e7bfadb3eb9f43eb0b670b908b479325722fee5.tar.gz librecrypt-8e7bfadb3eb9f43eb0b670b908b479325722fee5.tar.bz2 librecrypt-8e7bfadb3eb9f43eb0b670b908b479325722fee5.tar.xz | |
Add WITH_LIBAR2SIMPLIFIED=false + work on fuzzing code
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'librecrypt_encode.c')
| -rw-r--r-- | librecrypt_encode.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/librecrypt_encode.c b/librecrypt_encode.c index df16895..42d77d6 100644 --- a/librecrypt_encode.c +++ b/librecrypt_encode.c @@ -126,6 +126,7 @@ librecrypt_encode(char *out_buffer, size_t size, const void *binary, size_t len, #else +# ifndef FUZZ NONSTRING static const char lut[256u] = MAKE_ENCODING_LUT("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); @@ -225,4 +226,39 @@ main(void) } +# else + + +extern volatile size_t discarded_return_value; +volatile size_t discarded_return_value; + +int +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + const static char lut[256]; + char *out_buffer; + size_t out_size; + char pad; + size_t r; + + if (size < 3u) + return 0; + + out_size = ((size_t)data[0u] << 8) | (size_t)data[1u]; + if (out_size) { + out_buffer = malloc(out_size); + assert(out_buffer != NULL); + } else { + out_buffer = NULL; + } + pad = data[2u]; + + discarded_return_value = librecrypt_encode(out_buffer, out_size, &data[3u], size - 3u, lut, pad); + + free(out_buffer); + return 0; +} + + +# endif #endif |
