Skip to content

Fix overlapping memcpy when filtering TLVs by id - #134

Open
Hashim1999164 wants to merge 1 commit into
intel:masterfrom
Hashim1999164:fix-tlv-memcpy-overlap
Open

Fix overlapping memcpy when filtering TLVs by id#134
Hashim1999164 wants to merge 1 commit into
intel:masterfrom
Hashim1999164:fix-tlv-memcpy-overlap

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Sep 4, 2026

Copy link
Copy Markdown

Summary

When lldptool requests a single TLV id, get_tlvs compact matching entries forward with memcpy. Source and destination can overlap, so the copied bytes were corrupted (seen as garbled Port Description output). Switch that copy to memmove.

Separately, ieee8023_rchange can free a TLV and return TLV_OK while rxProcessFrame still walked later modules with that pointer. Stop the module walk once a handler returns TLV_OK so the next module cannot hit a use after free.

Closes #127

Test plan

  • Confirm get_tlvs uses memmove when compacting a matching TLV toward the front of the buffer
  • Confirm rxProcessFrame breaks out of the module list after TLV_OK
  • On a host that reproduced issue 127, query portDesc by tlvid and via full neighbor dump and compare the strings
  • Run the existing pytest suite under test/pytest when a full build environment is available

get_tlvs compacted matching TLVs with memcpy even when the source and
destination overlapped, which corrupted filtered neighbor TLV output.

Also stop delivering a TLV to later modules once one returns TLV_OK so
a handler that frees the TLV cannot leave a use after free.

Fixes: intel#127

Signed-off-by: Hashim1999164 <sardarhashim30@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

String corruption when querying individual TLV identifier with lldptool

1 participant