summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a1a7bcd)
raw | patch | inline | side by side (parent: a1a7bcd)
author | Florian Forster <octo@collectd.org> | |
Wed, 29 Feb 2012 19:47:08 +0000 (20:47 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 29 Feb 2012 19:48:39 +0000 (20:48 +0100) |
Change-Id: Ifa4db20a6b937912db77a214d2c0ef3eeebfa164
src/conntrack.c | patch | blob | history |
diff --git a/src/conntrack.c b/src/conntrack.c
index 4d6771244721c9d8e6c3049502de338e3b7e73e8..33236c45975c4d9c5c519e4defbfcd029c0b0821 100644 (file)
--- a/src/conntrack.c
+++ b/src/conntrack.c
value_t conntrack;
FILE *fh;
char buffer[64];
+ size_t buffer_len;
fh = fopen (CONNTRACK_FILE, "r");
if (fh == NULL)
return (-1);
+ memset (buffer, 0, sizeof (buffer));
if (fgets (buffer, sizeof (buffer), fh) == NULL)
{
fclose (fh);
}
fclose (fh);
- if (parse_value (buffer, &conntrack, DS_TYPE_GAUGE) == -1)
+ /* strip trailing newline. */
+ buffer_len = strlen (buffer);
+ while ((buffer_len > 0) && isspace ((int) buffer[buffer_len - 1]))
+ {
+ buffer[buffer_len - 1] = 0;
+ buffer_len--;
+ }
+
+ if (parse_value (buffer, &conntrack, DS_TYPE_GAUGE) != 0)
return (-1);
conntrack_submit (conntrack);