From 2c9cb8c9e02d290b5f37d439e5b6a8d2ca31e5f4 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 17 May 2021 10:02:36 +0930 Subject: [PATCH] devtools/onion: handle onions which are not 1300 bytes long. Signed-off-by: Rusty Russell --- devtools/onion.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devtools/onion.c b/devtools/onion.c index 63b57410e..e25440b8d 100644 --- a/devtools/onion.c +++ b/devtools/onion.c @@ -130,7 +130,7 @@ static struct route_step *decode_with_privkey(const tal_t *ctx, const u8 *onion, if (!hex_decode(hexprivkey, strlen(hexprivkey), &seckey, sizeof(seckey))) errx(1, "Invalid private key hex '%s'", hexprivkey); - packet = parse_onionpacket(tmpctx, onion, TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE), &why_bad); + packet = parse_onionpacket(tmpctx, onion, tal_bytelen(onion), &why_bad); if (!packet) errx(1, "Error parsing message: %s", onion_wire_name(why_bad)); @@ -147,7 +147,7 @@ static struct route_step *decode_with_privkey(const tal_t *ctx, const u8 *onion, static void do_decode(int argc, char **argv, const u8 *assocdata) { const tal_t *ctx = talz(NULL, tal_t); - u8 serialized[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)]; + u8 *serialized; struct route_step *step; if (argc != 4) @@ -161,7 +161,8 @@ static void do_decode(int argc, char **argv, const u8 *assocdata) while (isspace(hextemp[hexlen-1])) hexlen--; - if (!hex_decode(hextemp, hexlen, serialized, sizeof(serialized))) { + serialized = tal_hexdata(hextemp, hextemp, hexlen); + if (!serialized) { errx(1, "Invalid onion hex '%s'", hextemp); }