Merge pull request #2375 from hardening/minimize_diff

Check return value for fcntl()
This commit is contained in:
Norbert Federa 2015-02-10 14:56:30 +01:00
commit cc0db37725

View File

@ -452,13 +452,16 @@ BOOL SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCol
return FALSE; return FALSE;
flags = fcntl(fd, F_GETFL); flags = fcntl(fd, F_GETFL);
if (flags < 0)
return FALSE;
if (pNamedPipe->dwPipeMode & PIPE_NOWAIT) if (pNamedPipe->dwPipeMode & PIPE_NOWAIT)
flags = (flags | O_NONBLOCK); flags = (flags | O_NONBLOCK);
else else
flags = (flags & ~(O_NONBLOCK)); flags = (flags & ~(O_NONBLOCK));
fcntl(fd, F_SETFL, flags); if (fcntl(fd, F_SETFL, flags) < 0)
return FALSE;
} }
if (lpMaxCollectionCount) if (lpMaxCollectionCount)