Skip to content

Commit

Permalink
gossipd: check that we don't try to access a deleted gossip entry.
Browse files Browse the repository at this point in the history
We ignored this before, which meant that the DEVELOPER-mode check that we
delete the correct record didn't check that it wasn't already deleted.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Aug 9, 2019
1 parent 0edc0ae commit f9ecc76
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gossipd/gossip_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,13 @@ const u8 *gossip_store_get(const tal_t *ctx,
offset, gs->len, strerror(errno));
}

/* FIXME: We should skip over these deleted entries! */
msglen = be32_to_cpu(hdr.len) & ~GOSSIP_STORE_LEN_DELETED_BIT;
if (be32_to_cpu(hdr.len) & GOSSIP_STORE_LEN_DELETED_BIT)
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"gossip_store: get delete entry offset %"PRIu64
"/%"PRIu64"",
offset, gs->len);

msglen = be32_to_cpu(hdr.len);
checksum = be32_to_cpu(hdr.crc);
msg = tal_arr(ctx, u8, msglen);
if (pread(gs->fd, msg, msglen, offset + sizeof(hdr)) != msglen)
Expand Down

0 comments on commit f9ecc76

Please sign in to comment.