Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

CreateNamedPipes in RemComSvc.cpp leaks non-paged memory #28

@JWindram

Description

@JWindram

For the un-modified RemCom, this is not an issue, as the RemComSvc service stops and uninstalls itself when the last client disconnects. However, if someone were to modify the source so that the stop and uninstall didn't happen (i.e. the service was left running), then if many commands were executed, eventually the non-paged pool would be exhausted causing the server to become unstable.

This is because for each command that is executed, 3 named pipes are created (for stdin, stdout and stderr) and they are never closed.

The fix would be to add lines to close the pipes (free the handles) to the Execute method, following the WaitForSingleObject(hProcess...). Like so:
if ( !pMsg=bNoWait )
{
WaitForSIngleObject( hProcess, INFINITE );
GetExitCodeProcess( hProcess, pReturnCode );
//
CloseHandle( si.hStdOutput );
CloseHandle( si.hStdError );
CloseHandle( si.hStdInput );
//
}

Hopefully I'll get round to creating the fixed version soon, but I wanted to publicise this in case anyone chooses to modify the source for their own purposes.
Jim

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions