unixsock: check return value of chmod
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sat, 5 Dec 2015 14:16:36 +0000 (15:16 +0100)
committerFlorian Forster <octo@collectd.org>
Sat, 5 Dec 2015 20:45:57 +0000 (21:45 +0100)
CID #37948

Signed-off-by: Florian Forster <octo@collectd.org>
src/unixsock.c

index 2c1665f..8b2f339 100644 (file)
@@ -122,7 +122,16 @@ static int us_open_socket (void)
                return (-1);
        }
 
-       chmod (sa.sun_path, sock_perms);
+       status = chmod (sa.sun_path, sock_perms);
+       if (status == -1)
+       {
+               char errbuf[1024];
+               ERROR ("unixsock plugin: chmod failed: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+               close (sock_fd);
+               sock_fd = -1;
+               return (-1);
+       }
 
        status = listen (sock_fd, 8);
        if (status != 0)