Browse Source

gossipd: don't try to handle padding inside fromwire_ipaddr.

It makes it impossible to embed an ipaddr in another structure, since we
always try to skip over any zeroes, which may swallow a following field.

Do the skip specially for the case where we're parsing routing messages:
we never use padding for our own internal messages anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
7e022b522c
  1. 4
      gossipd/routing.c
  2. 3
      gossipd/test/run-find_route-specific.c
  3. 3
      gossipd/test/run-find_route.c
  4. 6
      lightningd/test/run-find_my_path.c
  5. 4
      wire/fromwire.c

4
gossipd/routing.c

@ -637,6 +637,10 @@ static struct ipaddr *read_addresses(const tal_t *ctx, const u8 *ser)
while (cursor && cursor < ser + max) {
struct ipaddr ipaddr;
/* Skip any padding */
while (max && cursor[0] == ADDR_TYPE_PADDING)
fromwire_u8(&cursor, &max);
/* BOLT #7:
*
* The receiving node SHOULD ignore the first `address

3
gossipd/test/run-find_route-specific.c

@ -31,6 +31,9 @@ bool fromwire_ipaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct ip
/* Generated stub for fromwire_node_announcement */
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
/* Generated stub for fromwire_u8 */
u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_u8 called!\n"); abort(); }
/* Generated stub for queue_broadcast */
void queue_broadcast(struct broadcast_state *bstate UNNEEDED,
const int type UNNEEDED,

3
gossipd/test/run-find_route.c

@ -24,6 +24,9 @@ bool fromwire_ipaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct ip
/* Generated stub for fromwire_node_announcement */
bool fromwire_node_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, size_t *plen UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, u8 **features UNNEEDED, u32 *timestamp UNNEEDED, struct pubkey *node_id UNNEEDED, u8 rgb_color[3] UNNEEDED, u8 alias[32] UNNEEDED, u8 **addresses UNNEEDED)
{ fprintf(stderr, "fromwire_node_announcement called!\n"); abort(); }
/* Generated stub for fromwire_u8 */
u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_u8 called!\n"); abort(); }
/* Generated stub for queue_broadcast */
void queue_broadcast(struct broadcast_state *bstate UNNEEDED,
const int type UNNEEDED,

6
lightningd/test/run-find_my_path.c

@ -40,12 +40,6 @@ struct log_book *new_log_book(const tal_t *ctx UNNEEDED,
/* Generated stub for new_topology */
struct chain_topology *new_topology(const tal_t *ctx UNNEEDED, struct log *log UNNEEDED)
{ fprintf(stderr, "new_topology called!\n"); abort(); }
/* Generated stub for opt_subd_debug */
char *opt_subd_debug(const char *optarg UNNEEDED, struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "opt_subd_debug called!\n"); abort(); }
/* Generated stub for opt_subd_dev_disconnect */
char *opt_subd_dev_disconnect(const char *optarg UNNEEDED, struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "opt_subd_dev_disconnect called!\n"); abort(); }
/* Generated stub for populate_peer */
void populate_peer(struct lightningd *ld UNNEEDED, struct peer *peer UNNEEDED)
{ fprintf(stderr, "populate_peer called!\n"); abort(); }

4
wire/fromwire.c

@ -198,10 +198,6 @@ bool fromwire_ipaddr(const u8 **cursor, size_t *max, struct ipaddr *addr)
fromwire(cursor, max, addr->addr, addr->addrlen);
addr->port = fromwire_u16(cursor, max);
/* Skip any post-padding */
while (*max && (*cursor)[0] == ADDR_TYPE_PADDING)
fromwire_u8(cursor, max);
return *cursor != NULL;
}

Loading…
Cancel
Save