Fixed copying junk data into initialized XEX memory when XEX is unencrypted.

This commit is contained in:
gibbed 2016-06-22 15:53:07 -05:00
parent e95a08fc87
commit 4aaca8cbf3
1 changed files with 2 additions and 3 deletions

View File

@ -630,12 +630,11 @@ int xe_xex2_read_image_basic_compressed(const xe_xex2_header_t* header,
switch (header->file_format_info.encryption_type) { switch (header->file_format_info.encryption_type) {
case XEX_ENCRYPTION_NONE: case XEX_ENCRYPTION_NONE:
if (exe_length - (p - source_buffer) > if (data_size > uncompressed_size - (d - buffer)) {
uncompressed_size - (d - buffer)) {
// Overflow. // Overflow.
return 1; return 1;
} }
memcpy(d, p, exe_length - (p - source_buffer)); memcpy(d, p, data_size);
break; break;
case XEX_ENCRYPTION_NORMAL: { case XEX_ENCRYPTION_NORMAL: {
const uint8_t* ct = p; const uint8_t* ct = p;