hasherezade / malware_training_vol1

Materials for Windows Malware Analysis training (volume 1)
1.94k stars 186 forks source link

Exercices-Mod1-L2PE-PeSelfLoad-Main.cpp - logical bug #6

Closed BlueSkeye closed 3 years ago

BlueSkeye commented 3 years ago

On line 202 you retrieve file size but fail to check for INVALID_FILE_SIZE (-1) return value. Should GetFileSize fail on a 32 bit system, allocation on line 204 will throw an std::bad_array_new_length exception.

Additionally you don't check either the result of the byte array allocation which could fail on very big files or in case of high memory pressure.