]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
ip rule: Require at least one argument for add
authorDavid Ahern <dsahern@gmail.com>
Tue, 30 Oct 2018 20:59:05 +0000 (13:59 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 1 Nov 2018 19:49:48 +0000 (12:49 -0700)
'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.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/iprule.c

index 74805b6cea2aa558b09de5496eac7ac9f5d9e3e4..a85a43904e6e2bdc987417cafbf2a6767414ab89 100644 (file)
@@ -696,6 +696,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;
        }