mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
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>
This commit is contained in:
parent
c2dd0cb295
commit
7e022b522c
5 changed files with 10 additions and 10 deletions
|
@ -637,6 +637,10 @@ static struct ipaddr *read_addresses(const tal_t *ctx, const u8 *ser)
|
||||||
while (cursor && cursor < ser + max) {
|
while (cursor && cursor < ser + max) {
|
||||||
struct ipaddr ipaddr;
|
struct ipaddr ipaddr;
|
||||||
|
|
||||||
|
/* Skip any padding */
|
||||||
|
while (max && cursor[0] == ADDR_TYPE_PADDING)
|
||||||
|
fromwire_u8(&cursor, &max);
|
||||||
|
|
||||||
/* BOLT #7:
|
/* BOLT #7:
|
||||||
*
|
*
|
||||||
* The receiving node SHOULD ignore the first `address
|
* The receiving node SHOULD ignore the first `address
|
||||||
|
|
|
@ -31,6 +31,9 @@ bool fromwire_ipaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct ip
|
||||||
/* Generated stub for fromwire_node_announcement */
|
/* 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)
|
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(); }
|
{ 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 */
|
/* Generated stub for queue_broadcast */
|
||||||
void queue_broadcast(struct broadcast_state *bstate UNNEEDED,
|
void queue_broadcast(struct broadcast_state *bstate UNNEEDED,
|
||||||
const int type UNNEEDED,
|
const int type UNNEEDED,
|
||||||
|
|
|
@ -24,6 +24,9 @@ bool fromwire_ipaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct ip
|
||||||
/* Generated stub for fromwire_node_announcement */
|
/* 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)
|
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(); }
|
{ 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 */
|
/* Generated stub for queue_broadcast */
|
||||||
void queue_broadcast(struct broadcast_state *bstate UNNEEDED,
|
void queue_broadcast(struct broadcast_state *bstate UNNEEDED,
|
||||||
const int type UNNEEDED,
|
const int type UNNEEDED,
|
||||||
|
|
|
@ -40,12 +40,6 @@ struct log_book *new_log_book(const tal_t *ctx UNNEEDED,
|
||||||
/* Generated stub for new_topology */
|
/* Generated stub for new_topology */
|
||||||
struct chain_topology *new_topology(const tal_t *ctx UNNEEDED, struct log *log UNNEEDED)
|
struct chain_topology *new_topology(const tal_t *ctx UNNEEDED, struct log *log UNNEEDED)
|
||||||
{ fprintf(stderr, "new_topology called!\n"); abort(); }
|
{ 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 */
|
/* Generated stub for populate_peer */
|
||||||
void populate_peer(struct lightningd *ld UNNEEDED, struct peer *peer UNNEEDED)
|
void populate_peer(struct lightningd *ld UNNEEDED, struct peer *peer UNNEEDED)
|
||||||
{ fprintf(stderr, "populate_peer called!\n"); abort(); }
|
{ fprintf(stderr, "populate_peer called!\n"); abort(); }
|
||||||
|
|
|
@ -198,10 +198,6 @@ bool fromwire_ipaddr(const u8 **cursor, size_t *max, struct ipaddr *addr)
|
||||||
fromwire(cursor, max, addr->addr, addr->addrlen);
|
fromwire(cursor, max, addr->addr, addr->addrlen);
|
||||||
addr->port = fromwire_u16(cursor, max);
|
addr->port = fromwire_u16(cursor, max);
|
||||||
|
|
||||||
/* Skip any post-padding */
|
|
||||||
while (*max && (*cursor)[0] == ADDR_TYPE_PADDING)
|
|
||||||
fromwire_u8(cursor, max);
|
|
||||||
|
|
||||||
return *cursor != NULL;
|
return *cursor != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue