From 9ae8c1869ae3f39c234790bf5f7c050d9a41ea77 Mon Sep 17 00:00:00 2001 From: Chad Fraleigh Date: Tue, 4 Jul 2023 15:44:32 -0700 Subject: [PATCH] Added bounds checking to LeaseSet2. --- libi2pd/LeaseSet.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libi2pd/LeaseSet.cpp b/libi2pd/LeaseSet.cpp index 675f6503..7138f4cc 100644 --- a/libi2pd/LeaseSet.cpp +++ b/libi2pd/LeaseSet.cpp @@ -394,6 +394,10 @@ namespace data size_t LeaseSet2::ReadStandardLS2TypeSpecificPart (const uint8_t * buf, size_t len) { size_t offset = 0; + + if(offset + 2 > len) // AKA (len < 2) + return 0; + // properties uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2; offset += propertiesLen; // skip for now. TODO: implement properties @@ -448,6 +452,10 @@ namespace data size_t LeaseSet2::ReadMetaLS2TypeSpecificPart (const uint8_t * buf, size_t len) { size_t offset = 0; + + if(offset + 2 > len) // AKA (len < 2) + return 0; + // properties uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2; offset += propertiesLen; // skip for now. TODO: implement properties