swrite: return error if fd is negative
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sun, 5 Jun 2016 11:53:17 +0000 (13:53 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Sun, 5 Jun 2016 11:53:17 +0000 (13:53 +0200)
src/daemon/common.c

index f82efe3..4c271d3 100644 (file)
@@ -273,6 +273,9 @@ ssize_t swrite (int fd, const void *buf, size_t count)
        ptr   = (const char *) buf;
        nleft = count;
        
+       if (fd < 0)
+               return (-1);
+
        /* checking for closed peer connection */
        pfd.fd = fd;
        pfd.events = POLLIN | POLLHUP;