From 2b5554fec057a7543311630667a922ebb30aa6ff Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Fri, 1 Apr 2016 01:35:52 +0000 Subject: [PATCH] mtest: Prevent access to uninitialized value. case 'g' makes use of value n, which is initialized for case 'b' and passe through to case 'g'. If case 'g' is called directly value 'n' is not initialized. Avoid the issue by initializing n before entering the switch. CID: 1006375 Reviewed by: bms --- usr.sbin/mtest/mtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/mtest/mtest.c b/usr.sbin/mtest/mtest.c index a28fab770e2..af522e21910 100644 --- a/usr.sbin/mtest/mtest.c +++ b/usr.sbin/mtest/mtest.c @@ -396,6 +396,7 @@ process_cmd(char *cmd, int s, int s6, FILE *fp __unused) while (isblank(*++line)) ; /* Skip whitespace. */ + n = 0; switch (*cmd) { case '?': usage(); @@ -611,7 +612,6 @@ process_cmd(char *cmd, int s, int s6, FILE *fp __unused) } /* First determine our current filter mode. */ - n = 0; if (getsourcefilter(af2sock(af, s, s6), ifindex, &su.sa, su.sa.sa_len, &fmode, &n, NULL) != 0) { warn("getsourcefilter");