@@ -479,12 +479,12 @@ class ReflectionContext
479
479
for (const typename T::Section *Hdr : SecHdrVec) {
480
480
uint32_t Offset = Hdr->sh_name ;
481
481
const char *Start = (const char *)StrTab + Offset;
482
- uint64_t Size = strnlen (Start, StrTabSize - Offset);
483
- if (Size > StrTabSize - Offset) {
482
+ uint64_t StringSize = strnlen (Start, StrTabSize - Offset);
483
+ if (StringSize > StrTabSize - Offset) {
484
484
Error = true ;
485
485
break ;
486
486
}
487
- std::string SecName (Start, Size );
487
+ std::string SecName (Start, StringSize );
488
488
if (SecName != Name)
489
489
continue ;
490
490
RemoteAddress SecStart =
@@ -495,15 +495,16 @@ class ReflectionContext
495
495
// sh_offset gives us the offset to the section in the file,
496
496
// while sh_addr gives us the offset in the process.
497
497
auto Offset = Hdr->sh_offset ;
498
- if (FileBuffer->allocatedSize () > Offset + Size ) {
498
+ if (FileBuffer->allocatedSize () < Offset + SecSize ) {
499
499
Error = true ;
500
500
break ;
501
501
}
502
502
auto *Buf = malloc (SecSize);
503
503
SecBuf = MemoryReader::ReadBytesResult (
504
504
Buf, [](const void *ptr) { free (const_cast <void *>(ptr)); });
505
505
memcpy ((void *)Buf,
506
- (const void *)((uint64_t )FileBuffer->base () + Offset), Size);
506
+ (const void *)((uint64_t )FileBuffer->base () + Offset),
507
+ SecSize);
507
508
} else {
508
509
SecBuf = this ->getReader ().readBytes (SecStart, SecSize);
509
510
}
0 commit comments