From a67c31458077d882da183d4045c9039418bf2d2b Mon Sep 17 00:00:00 2001 From: Neil McKee Date: Tue, 30 May 2023 09:41:25 -0700 Subject: [PATCH] bugfix in trimWhitespace (was over-trimming 1-char strings with leading whitespace) --- hsflowd.spec | 2 +- src/Linux/readNioCounters.c | 3 +++ src/Linux/util.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hsflowd.spec b/hsflowd.spec index b1bf26b..25357de 100644 --- a/hsflowd.spec +++ b/hsflowd.spec @@ -1,7 +1,7 @@ Summary: host sFlow daemon Name: hsflowd Version: 2.0.51 -Release: 17 +Release: 18 License: http://sflow.net/license.html Group: Applications/Internet URL: http://sflow.net diff --git a/src/Linux/readNioCounters.c b/src/Linux/readNioCounters.c index a2c221d..3a9e69c 100644 --- a/src/Linux/readNioCounters.c +++ b/src/Linux/readNioCounters.c @@ -65,6 +65,9 @@ extern "C" { if(sscanf(line, "%[^:]:%[^\n]", buf_var, buf_val) == 2) { char *tok_var = trimWhitespace(buf_var, my_strnlen(buf_var, MAX_PROC_LINE_CHARS-1)); char *tok_val = trimWhitespace(buf_val, my_strnlen(buf_val, MAX_PROC_LINE_CHARS-1)); + if(tok_var == NULL + || tok_val == NULL) + continue; if(readingMaster) { if(my_strequal(tok_var, "MII Status")) { diff --git a/src/Linux/util.c b/src/Linux/util.c index c7be8d9..d171fc2 100644 --- a/src/Linux/util.c +++ b/src/Linux/util.c @@ -554,7 +554,7 @@ extern "C" { while(isspace(*str)) { // also return NULL for a string with only spaces in it // (don't want that condition to slip through unnoticed) - if(++str >= end) + if(++str > end) return NULL; }