Skip to content

Commit

Permalink
gossipd: assert we're not blatting the version header.
Browse files Browse the repository at this point in the history
Suggested-by: whitslack
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Mar 31, 2021
1 parent 7b853d0 commit 7fbf728
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gossipd/gossip_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ static bool append_msg(int fd, const u8 *msg, u32 timestamp,
u32 msglen;
struct iovec iov[2];

/* Don't ever overwrite the version header! */
assert(*len);

msglen = tal_count(msg);
hdr.len = cpu_to_be32(msglen);
if (push)
Expand Down Expand Up @@ -621,6 +624,9 @@ static u32 delete_by_index(struct gossip_store *gs, u32 index, int type)
/* Should never get here during loading! */
assert(gs->writable);

/* Should never try to overwrite version */
assert(index);

#if DEVELOPER
const u8 *msg = gossip_store_get(tmpctx, gs, index);
assert(fromwire_peektype(msg) == type);
Expand Down

0 comments on commit 7fbf728

Please sign in to comment.