Skip to content

Commit

Permalink
Fix Heap-buffer-overflow (read) in TcpLayer::isDataValid. Closes #1130 (
Browse files Browse the repository at this point in the history
  • Loading branch information
sashashura authored Aug 4, 2023
1 parent 59bb2d1 commit 0725fa1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Packet++/header/TLVData.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,18 @@ namespace pcpp
if (record.isNull())
return resRec;

// record pointer is out-bounds of the TLV records memory
if ((record.getRecordBasePtr() - tlvDataBasePtr) < 0)
return resRec;

// record pointer is out-bounds of the TLV records memory
if (record.getRecordBasePtr() - tlvDataBasePtr + (int)record.getTotalSize() >= (int)tlvDataLen)
return resRec;

resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
if (resRec.getTotalSize() == 0)
resRec.assign(NULL);

// resRec pointer is out-bounds of the TLV records memory
if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
resRec.assign(NULL);

// resRec pointer is out-bounds of the TLV records memory
if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
resRec.assign(NULL);

return resRec;
}

Expand Down

0 comments on commit 0725fa1

Please sign in to comment.