mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
fuzz: add a target for base32/64 encoding
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
This commit is contained in:
committed by
Christian Decker
parent
07bb931fed
commit
5d987f2dec
@@ -11,6 +11,7 @@ FUZZ_COMMON_OBJS := \
|
||||
common/amount.o \
|
||||
common/addr.o \
|
||||
common/base32.o \
|
||||
common/base64.o \
|
||||
common/bech32.o \
|
||||
common/bigsize.o \
|
||||
common/json.o \
|
||||
|
||||
26
tests/fuzz/fuzz-base32-64.c
Normal file
26
tests/fuzz/fuzz-base32-64.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <tests/fuzz/libfuzz.h>
|
||||
|
||||
#include <common/base32.h>
|
||||
#include <common/base64.h>
|
||||
|
||||
void init(int *argc, char ***argv)
|
||||
{
|
||||
}
|
||||
|
||||
void run(const uint8_t *data, size_t size)
|
||||
{
|
||||
char *encoded;
|
||||
uint8_t *decoded;
|
||||
|
||||
encoded = b32_encode(NULL, data, size);
|
||||
decoded = b32_decode(NULL, encoded, strlen(encoded));
|
||||
assert(memcmp(decoded, data, size) == 0);
|
||||
tal_free(encoded);
|
||||
tal_free(decoded);
|
||||
|
||||
encoded = b64_encode(NULL, data, size);
|
||||
tal_free(encoded);
|
||||
}
|
||||
Reference in New Issue
Block a user