From 213c694b752ba35eade93fd3c3a286eab9c35eec Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Tue, 26 Jan 2021 14:42:31 +0100 Subject: [PATCH] collectd: snmp6 further improvements Return with "-1" if parsing fails in read function. Reduce buffersize of splitstring function. Signed-off-by: Nick Hainke --- .../collectd/patches/931-snmp6-add-ipv6-statistics.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/collectd/patches/931-snmp6-add-ipv6-statistics.patch b/utils/collectd/patches/931-snmp6-add-ipv6-statistics.patch index 8f50b0fe61..94bfbac59b 100644 --- a/utils/collectd/patches/931-snmp6-add-ipv6-statistics.patch +++ b/utils/collectd/patches/931-snmp6-add-ipv6-statistics.patch @@ -155,7 +155,7 @@ Signed-off-by: Nick Hainke +int snmp_read(char *ifname) { + FILE *fh; + char buffer[1024]; -+ char *fields[16]; ++ char *fields[2]; + int numfields; + int currline = 0; + derive_t data[76]; @@ -178,17 +178,17 @@ Signed-off-by: Nick Hainke + } + + while (fgets(buffer, 1024, fh) != NULL) { -+ numfields = strsplit(buffer, fields, 16); ++ numfields = strsplit(buffer, fields, 2); + + if (numfields < 2) -+ continue; ++ return -1; + + data[currline++] = atoll(fields[1]); + } + + fclose(fh); + -+ if (currline < 25) { ++ if (currline < 28) { + return -1; + } +