From b4d756830a4f0e13383fcd8d9e16e9154b9e766e Mon Sep 17 00:00:00 2001 From: Hardening Date: Thu, 12 Jun 2014 23:09:49 +0200 Subject: [PATCH] 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. --- winpr/libwinpr/file/file.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c index 8dacecf42..e8bc46b1c 100644 --- a/winpr/libwinpr/file/file.c +++ b/winpr/libwinpr/file/file.c @@ -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; } }