Skip to content

Commit

Permalink
collectd: snmp6 further improvements
Browse files Browse the repository at this point in the history
Return with "-1" if parsing fails in read function.
Reduce buffersize of splitstring function.

Signed-off-by: Nick Hainke <[email protected]>
  • Loading branch information
PolynomialDivision committed Jan 26, 2021
1 parent 922e5b1 commit 213c694
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/collectd/patches/931-snmp6-add-ipv6-statistics.patch
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Signed-off-by: Nick Hainke <[email protected]>
+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];
Expand All @@ -178,17 +178,17 @@ Signed-off-by: Nick Hainke <[email protected]>
+ }
+
+ 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;
+ }
+
Expand Down

0 comments on commit 213c694

Please sign in to comment.