Skip to content

Commit

Permalink
[BUGFIX] In RelocDirWrapper: fixed invalid cache initialization (Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Jul 15, 2022
1 parent 8da6518 commit 6107d80
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion parser/include/bearparser/pe/RelocDirWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RelocBlockWrapper : public ExeNodeWrapper
};

RelocBlockWrapper(Executable *pe, RelocDirWrapper *parentDir, size_t entryNumber)
: ExeNodeWrapper(pe, parentDir, entryNumber), cachedRaw(INVALID_ADDR), cachedMaxNum(-1) { this->parentDir = parentDir; wrap(); }
: ExeNodeWrapper(pe, parentDir, entryNumber), cachedRaw(INVALID_ADDR), cachedMaxNum(0) { this->parentDir = parentDir; wrap(); }

bool wrap();

Expand Down
4 changes: 2 additions & 2 deletions parser/pe/RelocDirWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ bool RelocBlockWrapper::wrap()
if (!reloc) return false;

size_t maxSize = reloc->SizeOfBlock;
parsedSize = sizeof(reloc->VirtualAddress) + sizeof(reloc->SizeOfBlock);
parsedSize = sizeof(IMAGE_BASE_RELOCATION); // the block begins with IMAGE_BASE_RELOCATION record
size_t entryId = 0;

while (parsedSize < maxSize) {
Expand All @@ -88,7 +88,7 @@ bool RelocBlockWrapper::wrap()
delete entry;
break;
}
this->parsedSize += sizeof(WORD);
this->parsedSize += sizeof(pe::BASE_RELOCATION_ENTRY);
this->entries.push_back(entry);
}
return true;
Expand Down

0 comments on commit 6107d80

Please sign in to comment.