Small fixes for better cross-platform compatibility (#200)

* Add ifdef check before the Microsoft-specific movsq in memory.cc

* Added ifdef before Microsoft-specific movsq and replaced with memcpy in other cases. In memory.cc

* Update image_sha_bytes_ from 16 to 20  xex_module.h

The value 16 is less than the expected value 20, causing a buffer overflow during sha1 finalization.

* Update image_sha_bytes_ loop from 16 to 20 iterations xex_module.cc

* Update mapped_memory_posix.cc: Must resize file to map_length.

* Should not map nullptr with MAP_FIXED flag. Update memory_posix.cc.
This commit is contained in:
none
2023-10-21 17:07:29 +02:00
committed by GitHub
parent 9f1605a2e7
commit d8aa14da73
5 changed files with 13 additions and 2 deletions

View File

@@ -1120,7 +1120,7 @@ void XexModule::Precompile() {
char fmtbuf[16];
for (unsigned i = 0; i < 16; ++i) {
for (unsigned i = 0; i < 20; ++i) {
sprintf_s(fmtbuf, "%X", image_sha_bytes_[i]);
image_sha_str_ += &fmtbuf[0];
}

View File

@@ -282,7 +282,7 @@ class XexModule : public xe::cpu::Module {
XexFormat xex_format_ = kFormatUnknown;
SecurityInfoContext security_info_ = {};
uint8_t image_sha_bytes_[16];
uint8_t image_sha_bytes_[20];
std::string image_sha_str_;
XexInfoCache info_cache_;
};