https://git.reactos.org/?p=reactos.git;a=commitdiff;h=22cb300805a6dd39c73bb…
commit 22cb300805a6dd39c73bb8ee39bbc390dd8eb5cc
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Feb 16 09:05:15 2019 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sat Feb 16 09:05:15 2019 +0100
[IPHLPAPI] Properly handle GetModuleBaseName failure
CID 1442662, 1442663
---
dll/win32/iphlpapi/iphlpapi_main.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/dll/win32/iphlpapi/iphlpapi_main.c b/dll/win32/iphlpapi/iphlpapi_main.c
index 5993c74f98..327b31717a 100644
--- a/dll/win32/iphlpapi/iphlpapi_main.c
+++ b/dll/win32/iphlpapi/iphlpapi_main.c
@@ -2289,7 +2289,7 @@ DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf)
static DWORD GetOwnerModuleFromPidEntry(DWORD OwningPid, TCPIP_OWNER_MODULE_INFO_CLASS
Class, PVOID Buffer, PDWORD pdwSize)
{
HANDLE Process;
- DWORD FileLen, PathLen;
+ DWORD FileLen, PathLen, Error;
WCHAR File[MAX_PATH], Path[MAX_PATH];
PTCPIP_OWNER_MODULE_BASIC_INFO BasicInfo;
@@ -2326,13 +2326,23 @@ static DWORD GetOwnerModuleFromPidEntry(DWORD OwningPid,
TCPIP_OWNER_MODULE_INFO
PathLen *= sizeof(WCHAR);
FileLen *= sizeof(WCHAR);
}
- else if (GetLastError() == ERROR_PARTIAL_COPY)
+ else
{
- wcscpy(File, L"System");
- wcscpy(Path, L"System");
+ Error = GetLastError();
+
+ if (Error == ERROR_PARTIAL_COPY)
+ {
+ wcscpy(File, L"System");
+ wcscpy(Path, L"System");
- PathLen = sizeof(L"System");
- FileLen = sizeof(L"System");
+ PathLen = sizeof(L"System");
+ FileLen = sizeof(L"System");
+ }
+ else
+ {
+ CloseHandle(Process);
+ return Error;
+ }
}
CloseHandle(Process);