google / google/netkat

PacketFieldManager::GetOrCreatePacketFieldHandle silently truncates index past 2^16 fields

Open Beginner friendly
#123 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39
Forks
9
Avg merge
11d 14h
Merged PRs (30d)
1

Description

PacketFieldHandle stores its index in a uint16_t (see the static_assert and comment in packet_field.h noting an expected max of ~65k fields). GetOrCreatePacketFieldHandle constructs PacketFieldHandle(field_names_.size()) with no bounds check, so once 65,537 or more distinct field names are interned, the index silently wraps and two different field names can alias the same handle, defeating the whole point of interning (safe O(1) equality). Suggest adding an explicit CHECK (e.g. CHECK_LE(field_names_.size(), std::numeric_limits::max())) so this fails loudly instead of corrupting data silently.

Contributor guide

Open the contributing guide

Research direction

Start with packet_field.h, including the PacketFieldHandle static_assert and comment, then trace GetOrCreatePacketFieldHandle where field_names_.size() is converted to a handle. Check the existing tests around packet-field interning, if present, and verify that exceeding the uint16_t capacity fails explicitly rather than allowing two names to share a handle.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.