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

buffer before trying to recv() from the pipe.
This commit is contained in:
Alex Villacís Lasso 2005-03-22 18:23:44 +00:00 committed by Alexandre Julliard
parent b718b0b019
commit 341f98ad8f
1 changed files with 3 additions and 1 deletions

View File

@ -1108,6 +1108,8 @@ BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
#ifdef FIONREAD #ifdef FIONREAD
int avail=0, fd, ret, flags; 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 ); ret = wine_server_handle_to_fd( hPipe, GENERIC_READ, &fd, &flags );
if (ret) if (ret)
{ {
@ -1153,7 +1155,7 @@ BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
*lpcbAvail = avail; *lpcbAvail = avail;
if (lpcbRead) if (lpcbRead)
*lpcbRead = 0; *lpcbRead = 0;
if (avail && lpvBuffer) if (avail && lpvBuffer && cbBuffer)
{ {
int readbytes = (avail < cbBuffer) ? avail : cbBuffer; int readbytes = (avail < cbBuffer) ? avail : cbBuffer;
readbytes = recv(fd, lpvBuffer, readbytes, MSG_PEEK); readbytes = recv(fd, lpvBuffer, readbytes, MSG_PEEK);