WriteFile and ReadFile does not check for INVALID_HANDLE_VALUE

This commit is contained in:
Martin Haimberger 2014-03-11 06:34:41 -07:00
parent e0966bbfff
commit 3808705652

View File

@ -311,6 +311,10 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
PVOID Object; PVOID Object;
BOOL status = TRUE; BOOL status = TRUE;
if (hFile == INVALID_HANDLE_VALUE) {
return FALSE;
}
/* /*
* from http://msdn.microsoft.com/en-us/library/windows/desktop/aa365467%28v=vs.85%29.aspx * from http://msdn.microsoft.com/en-us/library/windows/desktop/aa365467%28v=vs.85%29.aspx
* lpNumberOfBytesRead can be NULL only when the lpOverlapped parameter is not NULL. * lpNumberOfBytesRead can be NULL only when the lpOverlapped parameter is not NULL.
@ -464,6 +468,10 @@ BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
PVOID Object; PVOID Object;
BOOL status = TRUE; BOOL status = TRUE;
if (hFile == INVALID_HANDLE_VALUE) {
return FALSE;
}
if (!winpr_Handle_GetInfo(hFile, &Type, &Object)) if (!winpr_Handle_GetInfo(hFile, &Type, &Object))
return FALSE; return FALSE;