wire: add fromwire_tal_arrn() helper.

Does the allocation and copying; this is useful because we can
avoid being fooled into doing giant allocations.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-03-04 14:43:00 +10:30
committed by Christian Decker
parent 524d22e4cc
commit c92e782e22
5 changed files with 27 additions and 15 deletions

View File

@@ -104,10 +104,9 @@ static void printwire_addresses(const u8 **cursor, size_t *plen, size_t len)
static void printwire_encoded_short_ids(const u8 **cursor, size_t *plen, size_t len)
{
struct short_channel_id *scids;
u8 *arr = tal_arr(tmpctx, u8, len);
u8 *arr = fromwire_tal_arrn(tmpctx, cursor, plen, len);
fromwire_u8_array(cursor, plen, arr, len);
if (!*cursor)
if (!arr)
return;
printf("[");