]> git.itanic.dy.fi Git - rrdd/commitdiff
netstats_parser: Fix crash when network device names are undefined
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 20 Jun 2012 19:19:25 +0000 (22:19 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 20 Jun 2012 19:19:25 +0000 (22:19 +0300)
There is absolutely nothing this parser can do without the network
names. If the pointer happens to be zero, all we can do is to bail out
with a error print. Not handling this situation will lead to a crash.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
parser.c

index d7aa293065b324dda750aceb2fe54062116cc7c6..fcc319225178f06a0cf716f754ef948211bd0acd 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -242,6 +242,11 @@ int netstats_parser(char *rrd_data, void *parser_data)
        int max_str = RRD_DATA_MAX_LEN;
        int ret;
 
+       if (!parser_data) {
+               pr_err("No device names specified\n");
+               return -1;
+       }
+
        while(*iface_name) {
                pr_info("getting data for iface %s\n", *iface_name);
                ret = get_iface_stats(*iface_name, &stat);