silverf0x / RpcView

RpcView is a free tool to explore and decompile Microsoft RPC interfaces
GNU General Public License v3.0
895 stars 247 forks source link

RpcCommon/Misc.c EnumProcess, incorrect check of function return value #27

Closed hfiref0x closed 5 years ago

hfiref0x commented 5 years ago

There is an incorrect check of function return value in EnumProcess function

https://github.com/silverf0x/RpcView/blob/c108da277be48accb3c6aaeb4af752a2028069bf/RpcCommon/Misc.c#L52

and then

https://github.com/silverf0x/RpcView/blob/c108da277be48accb3c6aaeb4af752a2028069bf/RpcCommon/Misc.c#L53

and in the end of function

https://github.com/silverf0x/RpcView/blob/c108da277be48accb3c6aaeb4af752a2028069bf/RpcCommon/Misc.c#L64

When CreateToolhelp32Snapshot fails it return INVALID_HANDLE_VALUE (https://docs.microsoft.com/en-us/windows/desktop/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot#return-value) which is not NULL. Thus failed call to CreateToolhelp32Snapshot will lead to invalid handle passed to CloseHandle.

CreateToolhelp32Snapshot return value must be checked against INVALID_HANDLE_VALUE.