Skip to content

Commit

Permalink
gossmap: don't crash if we hit a zero-length record.
Browse files Browse the repository at this point in the history
We have a report of this happening under ZFS.  We cannot do much if
this really is a problem where we can't read back what we write, but
this avoids the immediate crash.

Fixes: ElementsProject#7971
Signed-off-by: Rusty Russell <[email protected]>
Changelog-Fixed: gossmap: occasional crash (at least on ZFS) reading gossip_store.
  • Loading branch information
rustyrussell committed Feb 6, 2025
1 parent 1f26e34 commit 1f45ef8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/gossmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ static bool map_catchup(struct gossmap *map, bool *changed)
if (map->map_end + reclen > map->map_size)
break;

/* FIXME: In corruption, we can see zeroes here: don't crash. */
if (be16_to_cpu(ghdr.len) < sizeof(be16))
break;

off = map->map_end + sizeof(ghdr);
type = map_be16(map, off);
if (type == WIRE_CHANNEL_ANNOUNCEMENT) {
Expand Down

0 comments on commit 1f45ef8

Please sign in to comment.