teamspeak2: fix potential use after close
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 4 Dec 2015 18:09:28 +0000 (19:09 +0100)
committerFlorian Forster <octo@collectd.org>
Sat, 5 Dec 2015 07:41:03 +0000 (08:41 +0100)
If connecting to the last host fails, we exit the loop
with a closed fd, which we try to fdopen() later on.

CID #38038

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

index 2552ad3..c8bf483 100644 (file)
@@ -258,6 +258,7 @@ static int tss2_get_socket (FILE **ret_read_fh, FILE **ret_write_fh)
                        WARNING ("teamspeak2 plugin: connect failed: %s",
                                        sstrerror (errno, errbuf, sizeof (errbuf)));
                        close (sd);
+                       sd = -1;
                        continue;
                }