]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iproute: disallow ip rule del without parameters
authorAndrey Jr. Melnikov <temnota.am@gmail.com>
Wed, 24 Aug 2016 20:43:00 +0000 (23:43 +0300)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 1 Sep 2016 15:41:37 +0000 (08:41 -0700)
Disallow run `ip rule del` without any parameter to avoid delete any first
rule from table.

Signed-off-by: Andrey Jr. Melnikov <temnota.am@gmail.com>
ip/iprule.c

index 8f242067f6178af8220a436bff7b9fdc505084db..70562c55314ee8fc649226c305d908aa1b1a2358 100644 (file)
@@ -346,6 +346,11 @@ static int iprule_modify(int cmd, int argc, char **argv)
                req.r.rtm_type = RTN_UNICAST;
        }
 
+       if (cmd == RTM_DELRULE && argc == 0) {
+               fprintf(stderr, "\"ip rule del\" requires arguments.\n");
+               return -1;
+       }
+
        while (argc > 0) {
                if (strcmp(*argv, "not") == 0) {
                        req.r.rtm_flags |= FIB_RULE_INVERT;