Skip to content

Commit dd3167a

Browse files
committed
Avoid integer overflow in loadFile
1 parent b7272b5 commit dd3167a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/core/hexeditor.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ bool HexEditor::loadFile(string path) {
9898
this->current_data.clear();
9999
this->current_data.shrink_to_fit();
100100

101+
ifs.seekg(0, std::ios::end);
102+
this->fileSize = ifs.tellg();
103+
ifs.seekg(0, std::ios::beg);
104+
101105
// copies all data into buffer
102106
this->current_data.insert(this->current_data.begin(), std::istreambuf_iterator<char>(ifs), {});
103107

104-
this->fileSize = this->current_data.size();
105108
this->bytesRead = this->fileSize;
106109

107110
return true;

0 commit comments

Comments
 (0)