diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-07 18:02:12 -0800 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-07 18:02:12 -0800 |
commit | b1cef469a3d6ae4a9f0ca159b6a3f93d92ff585a (patch) | |
tree | 4b59ead85c5245ea77e53385b50169e2cca7f0b6 | |
parent | 4dcdfbf80d9fbed98e5fa2fde914844386a28535 (diff) | |
download | psutil-win-open-files-fixes.tar.gz |
check file type before duplicating the handlewin-open-files-fixes
-rw-r--r-- | psutil/arch/windows/process_handles.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/psutil/arch/windows/process_handles.c b/psutil/arch/windows/process_handles.c index 1872c572..16d04aee 100644 --- a/psutil/arch/windows/process_handles.c +++ b/psutil/arch/windows/process_handles.c @@ -181,6 +181,10 @@ psutil_get_open_files(DWORD dwPid, HANDLE hProcess) { if ((ULONG_PTR)hHandle->UniqueProcessId != dwPid) goto loop_cleanup; + // not a file + if (GetFileType((HANDLE)hHandle->HandleValue) != FILE_TYPE_DISK) + goto loop_cleanup; + if (!DuplicateHandle(hProcess, (HANDLE)hHandle->HandleValue, GetCurrentProcess(), |