Skip to contentSkip to conversation

iptables-restore -c faults if there are no counters

PATCH New Thomas Woerner 1 participant 1 message Feb 26, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iptables-restore -c faults if there are no counters

Hello,

the function parse_counters does not check the input string and is producing a fault if it is NULL.

Thanks,
Thomas

Signature · 4 lines
Thomas Woerner, Software Engineer      Phone: +49-711-96437-0
Red Hat GmbH                           Fax  : +49-711-96437-111
Hauptstaetterstr. 58                   Email: [email protected]
D-70178 Stuttgart                      Web  : http://www.redhat.de/
iptables-restore.c renamed from iptables-restore.c.counters +5 -1
@@ -71,7 +71,11 @@
 
 int parse_counters(char *string, struct ipt_counters *ctr)
 {
-	return (sscanf(string, "[%llu:%llu]", &ctr->pcnt, &ctr->bcnt) == 2);
+	if (string != NULL)
+		return (sscanf(string, "[%llu:%llu]", &ctr->pcnt, &ctr->bcnt)
+			== 2);
+	else
+		return (0 == 2);
 }
 
 /* global new argv and argc */