Skip to contentSkip to conversation

ip rule: Require at least one argument for add

PATCH In review David Ahern 2 participants 2 messages Oct 31, 2018 – Nov 2, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip rule: Require at least one argument for add

From: David Ahern <[email protected]>

'ip rule add' with no additional arguments just adds another rule for the main table - which exists by default. Require at least 1 argument similar to delete.

---
 ip/iprule.c | 5 +++++
 1 file changed, 5 insertions(+)
ip/iprule.c +5 -0
index d89d808d8909..b465a80785b1 100644
@@ -691,6 +691,11 @@ static int iprule_modify(int cmd, int argc, char **argv)
 	};
 
 	if (cmd == RTM_NEWRULE) {
+		if (argc == 0) {
+			fprintf(stderr,
+				"\"ip rule add\" requires arguments.\n");
+			return -1;
+		}
 		req.n.nlmsg_flags |= NLM_F_CREATE|NLM_F_EXCL;
 		req.frh.action = FR_ACT_TO_TBL;
 	}
Signature · 1 line
2.11.0