Skip to content

Commit 05437c1

Browse files
committed
Added bounds checking to LeaseSet2.
1 parent 5860a09 commit 05437c1

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

libi2pd/LeaseSet.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ namespace data
398398
std::shared_ptr<LocalDestination> dest)
399399
{
400400
size_t offset = 0;
401+
402+
if(offset + 2 > len) // AKA (len < 2)
403+
return 0;
404+
401405
// properties
402406
uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2;
403407
offset += propertiesLen; // skip for now. TODO: implement properties
@@ -477,6 +481,10 @@ namespace data
477481
size_t LeaseSet2::ReadMetaLS2TypeSpecificPart (const uint8_t * buf, size_t len)
478482
{
479483
size_t offset = 0;
484+
485+
if(offset + 2 > len) // AKA (len < 2)
486+
return 0;
487+
480488
// properties
481489
uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2;
482490
offset += propertiesLen; // skip for now. TODO: implement properties

0 commit comments

Comments
 (0)