Skip to content

Commit 7fbf728

Browse files
committed
gossipd: assert we're not blatting the version header.
Suggested-by: whitslack Signed-off-by: Rusty Russell <[email protected]>
1 parent 7b853d0 commit 7fbf728

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

gossipd/gossip_store.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ static bool append_msg(int fd, const u8 *msg, u32 timestamp,
8585
u32 msglen;
8686
struct iovec iov[2];
8787

88+
/* Don't ever overwrite the version header! */
89+
assert(*len);
90+
8891
msglen = tal_count(msg);
8992
hdr.len = cpu_to_be32(msglen);
9093
if (push)
@@ -621,6 +624,9 @@ static u32 delete_by_index(struct gossip_store *gs, u32 index, int type)
621624
/* Should never get here during loading! */
622625
assert(gs->writable);
623626

627+
/* Should never try to overwrite version */
628+
assert(index);
629+
624630
#if DEVELOPER
625631
const u8 *msg = gossip_store_get(tmpctx, gs, index);
626632
assert(fromwire_peektype(msg) == type);

0 commit comments

Comments
 (0)