From: Sebastian Harl Date: Sun, 5 Jun 2016 12:27:11 +0000 (+0200) Subject: Merge pull request #1746 from rubenk/swrite-check-for-open-fd X-Git-Tag: collectd-5.6.0~229 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=3f8fcdf9a0184e2e2cb3098a94f0223cf54373d4;hp=edd9af8a874ebc9f2a7f02846807229a648917db Merge pull request #1746 from rubenk/swrite-check-for-open-fd swrite: return error if fd is negative --- diff --git a/src/daemon/common.c b/src/daemon/common.c index f82efe33..4c271d34 100644 --- a/src/daemon/common.c +++ b/src/daemon/common.c @@ -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;