Don't forget to SetLastError() on disconnection

Otherwise if the last error was a ERROR_NO_DATA we have no indication that
the pipe has been closed.
This commit is contained in:
Hardening 2014-06-12 23:09:49 +02:00
parent 33b4407314
commit b4d756830a

View File

@ -368,12 +368,7 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
if (io_status == 0)
{
switch (errno)
{
case ECONNRESET:
SetLastError(ERROR_BROKEN_PIPE);
break;
}
SetLastError(ERROR_BROKEN_PIPE);
status = FALSE;
}
else if (io_status < 0)
@ -385,6 +380,9 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
case EWOULDBLOCK:
SetLastError(ERROR_NO_DATA);
break;
default:
SetLastError(ERROR_BROKEN_PIPE);
break;
}
}