Skip to content

Commit

Permalink
Update buffer.cpp (#200)
Browse files Browse the repository at this point in the history
set error to PEERR_OPEN if CreateFileA or GetFileSize fails
  • Loading branch information
cvspvr authored Apr 11, 2024
1 parent b43ff37 commit 015345d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pe-parser-library/src/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,15 @@ bounded_buffer *readFileToFileBuffer(const char *filePath) {
FILE_ATTRIBUTE_NORMAL,
nullptr);
if (h == INVALID_HANDLE_VALUE) {
PE_ERR(PEERR_OPEN);
return nullptr;
}

DWORD fileSize = GetFileSize(h, nullptr);

if (fileSize == INVALID_FILE_SIZE) {
CloseHandle(h);
PE_ERR(PEERR_OPEN);
return nullptr;
}

Expand Down

0 comments on commit 015345d

Please sign in to comment.