lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 21 Dec 2018 22:53:35 -0800
From:   Eric Dumazet <edumazet@...gle.com>
To:     David Ahern <dsahern@...il.com>,
        Stephen Hemminger <stephen@...workplumber.org>
Cc:     netdev <netdev@...r.kernel.org>,
        Eric Dumazet <edumazet@...gle.com>,
        Eric Dumazet <eric.dumazet@...il.com>
Subject: [PATCH iproute2] nstat: fix load_ugly_table() limits

A recent change reduced max line length from 4096 to 2048 bytes,
but we already have lines above the 2048 threshold, and we keep
adding more SNMP counters in linux.

Switch to getline() and do not worry about future kernel changes.

Fixes: da8034a01904 ("misc: avoid snprintf warnings in ss and nstat")
Signed-off-by: Eric Dumazet <edumazet@...gle.com>
---
 misc/nstat.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/misc/nstat.c b/misc/nstat.c
index 88f1c7698243235b12f58cd067afce488af1be4c..653580eae0603327ea654510ae1f23a79578c1fe 100644
--- a/misc/nstat.c
+++ b/misc/nstat.c
@@ -177,11 +177,13 @@ static int count_spaces(const char *line)
 
 static void load_ugly_table(FILE *fp)
 {
-	char buf[2048];
+	char *buf = NULL;
+	size_t buflen = 0;
+	ssize_t nread;
 	struct nstat_ent *db = NULL;
 	struct nstat_ent *n;
 
-	while (fgets(buf, sizeof(buf), fp) != NULL) {
+	while ((nread = getline(&buf, &buflen, fp)) != -1) {
 		char idbuf[4096];
 		int  off;
 		char *p;
@@ -218,7 +220,8 @@ static void load_ugly_table(FILE *fp)
 			p = next;
 		}
 		n = db;
-		if (fgets(buf, sizeof(buf), fp) == NULL)
+		nread = getline(&buf, &buflen, fp);
+		if (nread == -1)
 			abort();
 		count2 = count_spaces(buf);
 		if (count2 > count1)
@@ -237,6 +240,7 @@ static void load_ugly_table(FILE *fp)
 				n = n->next;
 		} while (p > buf + off + 2);
 	}
+	free(buf);
 
 	while (db) {
 		n = db;
-- 
2.20.1.415.g653613c723-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ