Using PCHAR on any valid (non-NULL-) pointer causes crash
Bueddl opened this issue · 1 comments
Bueddl commented
The buffer allocation inside ReadMemoryString
(see: ReClass 2015/stdafx.cpp @ Line 93) seems one byte too small to me. There will be 64 bytes allocated and a read of the same size will be done afterwards. The problem reveals when placing the NULL-termination at buffer[bytesRead]
, which is already outside the bounds of our buffer and will lead to application crash through heap corruption later on.
In my opinion the allocation should read
auto buffer = std::make_unique<char[]>( max + 1 );
instead of
auto buffer = std::make_unique<char[]>( max );
Handling NULL-pointers is not affected as the preceding call to ReadMemory
will fail and branch into an alternative code path.
ajkhoury commented
Thanks, nice catch! Will fix that up.