From 5dddd977f26f956ca61c4bb89e28c0f25d013ae2 Mon Sep 17 00:00:00 2001 From: Hardening Date: Tue, 10 Feb 2015 10:08:39 +0100 Subject: [PATCH] Check return value for fcntl() --- winpr/libwinpr/pipe/pipe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/winpr/libwinpr/pipe/pipe.c b/winpr/libwinpr/pipe/pipe.c index e7b2d51e3..c5524d239 100644 --- a/winpr/libwinpr/pipe/pipe.c +++ b/winpr/libwinpr/pipe/pipe.c @@ -452,13 +452,16 @@ BOOL SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCol return FALSE; flags = fcntl(fd, F_GETFL); + if (flags < 0) + return FALSE; if (pNamedPipe->dwPipeMode & PIPE_NOWAIT) flags = (flags | O_NONBLOCK); else flags = (flags & ~(O_NONBLOCK)); - fcntl(fd, F_SETFL, flags); + if (fcntl(fd, F_SETFL, flags) < 0) + return FALSE; } if (lpMaxCollectionCount)