Commit 341f98ad authored by Alex Villacís Lasso's avatar Alex Villacís Lasso Committed by Alexandre Julliard

PeekNamedPipe now checks both for a NULL buffer and a zero-length

buffer before trying to recv() from the pipe.
parent b718b0b0
......@@ -1108,6 +1108,8 @@ BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
#ifdef FIONREAD
int avail=0, fd, ret, flags;
TRACE("(%p,%p,%lu,%p,%p,%p)\n", hPipe, lpvBuffer, cbBuffer, lpcbRead, lpcbAvail, lpcbMessage);
ret = wine_server_handle_to_fd( hPipe, GENERIC_READ, &fd, &flags );
if (ret)
{
......@@ -1153,7 +1155,7 @@ BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
*lpcbAvail = avail;
if (lpcbRead)
*lpcbRead = 0;
if (avail && lpvBuffer)
if (avail && lpvBuffer && cbBuffer)
{
int readbytes = (avail < cbBuffer) ? avail : cbBuffer;
readbytes = recv(fd, lpvBuffer, readbytes, MSG_PEEK);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment