From 6f1b0588362da8943f58404ab03c9c59914be5ad Mon Sep 17 00:00:00 2001 From: Force Charlie Date: Wed, 6 Jan 2021 15:48:46 +0800 Subject: [PATCH] Privexec: 4.3.1 fix detect git-for-windows git.exe wapper subsystem failed. git-for-windows PointerToSymbolTable value is incorrect --- CMakeLists.txt | 2 +- vendor/bela.lock | 2 +- vendor/bela/src/belawin/pe/file.cc | 1 - vendor/bela/src/belawin/pe/string.cc | 8 +++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ca3e7b3..9e8a3a61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ endif() # set(PRIVEXEC_VERSION_MAJOR 4) set(PRIVEXEC_VERSION_MINOR 3) -set(PRIVEXEC_VERSION_PATCH 0) +set(PRIVEXEC_VERSION_PATCH 1) set(PACKAGE_VERSION "${PRIVEXEC_VERSION_MAJOR}.${PRIVEXEC_VERSION_MINOR}.${PRIVEXEC_VERSION_PATCH}") string(TOLOWER "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" COMPILER_ARCH_ID) diff --git a/vendor/bela.lock b/vendor/bela.lock index bccf8675..8f4a7610 100644 --- a/vendor/bela.lock +++ b/vendor/bela.lock @@ -1 +1 @@ -https://github.com/fcharlie/bela/tree/303e8bc883db52d8e9adbab1bee66ef6bedd7fd8 +https://github.com/fcharlie/bela/tree/9e7783d3d4545cce1ca2ff2e7b51abce93a452f8 diff --git a/vendor/bela/src/belawin/pe/file.cc b/vendor/bela/src/belawin/pe/file.cc index 1ea078c2..2931045d 100644 --- a/vendor/bela/src/belawin/pe/file.cc +++ b/vendor/bela/src/belawin/pe/file.cc @@ -118,7 +118,6 @@ bool File::ParseFile(bela::error_code &ec) { if (!ReadAt(&dh, sizeof(DosHeader), 0, ec)) { return false; } - constexpr auto x = 0x3c; int64_t base = 0; if (bela::fromle(dh.e_magic) == IMAGE_DOS_SIGNATURE) { diff --git a/vendor/bela/src/belawin/pe/string.cc b/vendor/bela/src/belawin/pe/string.cc index 5b03348e..92207124 100644 --- a/vendor/bela/src/belawin/pe/string.cc +++ b/vendor/bela/src/belawin/pe/string.cc @@ -38,14 +38,16 @@ bool File::readStringTable(bela::error_code &ec) { return true; } auto offset = fh.PointerToSymbolTable + COFFSymbolSize * fh.NumberOfSymbols; + if (static_cast(offset + 4) >= size) { + return true; + } uint32_t l = 0; - if (!ReadAt(&l, sizeof(l), offset, ec)) { return false; } l = bela::fromle(l); - if (l <= 4) { - return false; + if (l <= 4 || static_cast(l + offset) > size) { + return true; } l -= 4; if (stringTable.data = reinterpret_cast(HeapAlloc(GetProcessHeap(), 0, l)); stringTable.data == nullptr) {