From d285229b5efe29e2f841a3dc8e933a7984a0844a Mon Sep 17 00:00:00 2001 From: Oleksii Shevchuk Date: Thu, 2 Jul 2020 10:55:26 +0300 Subject: [PATCH] client/windows: fix GetModuleFileNameA --- client/sources/MyLoadLibrary.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/sources/MyLoadLibrary.c b/client/sources/MyLoadLibrary.c index e434f64d..fed2b374 100644 --- a/client/sources/MyLoadLibrary.c +++ b/client/sources/MyLoadLibrary.c @@ -410,12 +410,12 @@ DWORD CALLBACK MyGetModuleFileNameA(HMODULE hModule, LPSTR lpStr, DWORD dwSize) DWORD dwRet = MemoryModuleFileNameA(lib->module, lpStr, dwSize); if (dwRet == 0xFFFFFFFF) { size_t reqSize = strlen(lib->fileName); - if (reqSize < dwSize) { + if (reqSize > dwSize) { SetLastError(ERROR_INSUFFICIENT_BUFFER); dwRet = 0; } else { memcpy(lpStr, lib->fileName, reqSize); - if (dwSize+1 == reqSize) { + if (dwSize >= reqSize + 1) { lpStr[reqSize] = '\0'; } dwRet = reqSize;