mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
libfuzz: add a NULL-termination in to_string
It's more useful if we actually want to use the output as, well, a string.. Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
This commit is contained in:
parent
45bb1bfa3c
commit
506d524508
@ -46,6 +46,7 @@ FUZZ_COMMON_OBJS := \
|
||||
wire/onion_wiregen.o \
|
||||
wire/peer_wire.o \
|
||||
wire/peer_wiregen.o \
|
||||
wire/tlvstream.o \
|
||||
wire/towire.o \
|
||||
wire/wire_io.o \
|
||||
wire/wire_sync.o
|
||||
|
@ -34,10 +34,11 @@ const uint8_t **get_chunks(const void *ctx, const uint8_t *data,
|
||||
|
||||
char *to_string(const tal_t *ctx, const u8 *data, size_t data_size)
|
||||
{
|
||||
char *string = tal_arr(ctx, char, data_size);
|
||||
char *string = tal_arr(ctx, char, data_size + 1);
|
||||
|
||||
for (size_t i = 0; i < data_size; i++)
|
||||
string[i] = (char) data[i] % (CHAR_MAX + 1);
|
||||
string[data_size] = '\0';
|
||||
|
||||
return string;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user