Code

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 2552ad305ffcaa51decb9ab490764a1cc907e4fb..c8bf48361230a14a9d1d940008320d34dadfad11 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;
                }