Code

utils_mount.c: check for null before dereferencing
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 4 Dec 2015 20:18:27 +0000 (21:18 +0100)
committerFlorian Forster <octo@collectd.org>
Sat, 5 Dec 2015 07:48:59 +0000 (08:48 +0100)
CID #38025

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

index afeb39e1162af515ddac44dfda578b3a76c2cdb4..f2b79439adc77e70b495cf7079a38ef18997dfbc 100644 (file)
@@ -760,13 +760,13 @@ void cu_mount_freelist (cu_mount_t *list)
 char *
 cu_mount_checkoption(char *line, char *keyword, int full)
 {
-       char *line2, *l2;
-       int l = strlen(keyword);
-       char *p1, *p2;
+       char *line2, *l2, *p1, *p2;
+       int l;
 
        if(line == NULL || keyword == NULL) {
                return NULL;
        }
+
        if(full != 0) {
                full = 1;
        }
@@ -780,6 +780,7 @@ cu_mount_checkoption(char *line, char *keyword, int full)
                l2++;
        }
 
+       l = strlen(keyword);
        p1 = line - 1;
        p2 = strchr(line, ',');
        do {