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_realise_salts.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_realise_salts.c')
| -rw-r--r-- | librecrypt_realise_salts.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/librecrypt_realise_salts.c b/librecrypt_realise_salts.c index 8f6d4eb..c7b7071 100644 --- a/librecrypt_realise_salts.c +++ b/librecrypt_realise_salts.c @@ -164,6 +164,7 @@ erange: #else +# ifndef FUZZ # define LARGE "99999999999999999999999999999999999999999999999999999999999999" @@ -313,4 +314,62 @@ main(void) } +#else + + +int +LLVMFuzzerInitialize(int *argc, char ***argv) +{ + static unsigned char not_random = 5; + +#if defined(__linux__) + libtest_getrandom_real = 0; +#endif + libtest_getentropy_real = 0; + libtest_random_pattern = ¬_random; + libtest_random_pattern_length = 1u; + libtest_random_pattern_offset = 0u; + + (void) argc; + (void) argv; + return 0; +} + + +int +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + char *out_buffer, *settings; + size_t out_size; + ssize_t r; + + if (size < 2u) + 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; + } + data = &data[2u]; + size -= 2u; + settings = malloc(size + 1u); + assert(settings != NULL); + memcpy(settings, data, size); + settings[size] = '\0'; + + r = librecrypt_realise_salts(out_buffer, out_size, settings, NULL, NULL); + if (out_size && r >= 0) { + assert(strlen(out_buffer) < out_size); + assert((size_t)r >= strlen(out_buffer)); + } + + free(out_buffer); + return 0; +} + + +# endif #endif |
