mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 00:24:19 +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:
committed by
Christian Decker
parent
45bb1bfa3c
commit
506d524508
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user