gossipd: assert we're not blatting the version header.

Suggested-by: whitslack
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-03-17 12:27:27 +10:30
parent 7b853d0fa5
commit 7fbf728a34

View File

@@ -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)
@@ -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);