Skip to content

Commit

Permalink
fix(gossip): contact-info cache OOB (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNineteen authored Jan 16, 2025
1 parent bfcd3bd commit c017eab
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/gossip/data.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,13 @@ pub const ContactInfo = struct {
.ipv6 => SocketAddr.initIpv6(addr.asV6(), port),
};
socket.sanitize() catch continue;
self.cache[@intFromEnum(socket_entry.key)] = socket;

const cache_index = @intFromEnum(socket_entry.key);
if (cache_index >= SOCKET_CACHE_SIZE) {
// warn
continue;
}
self.cache[cache_index] = socket;
}
}

Expand Down

0 comments on commit c017eab

Please sign in to comment.