Skip to content

Commit d443aa6

Browse files
committed
fix tlv
1 parent 6fa6a84 commit d443aa6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/serialiser/rstlvbase.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,17 +567,17 @@ bool GetTlvString(const void *data, uint32_t size, uint32_t *offset,
567567
uint32_t tlvsize = GetTlvSize(tlvstart);
568568

569569
/* check that there is size */
570-
uint32_t tlvend = *offset + tlvsize;
571-
if (size < tlvend)
570+
if (tlvsize > size || *offset > size - tlvsize)
572571
{
573572
#ifdef TLV_BASE_DEBUG
574573
std::cerr << "GetTlvString() FAILED - not enough space" << std::endl;
575574
std::cerr << "GetTlvString() size: " << size << std::endl;
576575
std::cerr << "GetTlvString() tlvsize: " << tlvsize << std::endl;
577-
std::cerr << "GetTlvString() tlvend: " << tlvend << std::endl;
576+
std::cerr << "GetTlvString() offset: " << *offset << std::endl;
578577
#endif
579578
return false;
580579
}
580+
uint32_t tlvend = *offset + tlvsize;
581581

582582
if (type != tlvtype)
583583
{

0 commit comments

Comments
 (0)