multipath: fix max array size in print_cmd_valid
authorBenjamin Marzinski <bmarzins@redhat.com>
Tue, 9 Oct 2018 23:03:10 +0000 (18:03 -0500)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 10 Oct 2018 06:09:40 +0000 (08:09 +0200)
The code is attempting to verify that 0 <= k < 3
However, sizeof(val) is 12, assuming 4 byte integers. The check needs to
take integer size into account. Found by coverity.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
multipath/main.c

index fc5bf16..d5aad95 100644 (file)
@@ -482,7 +482,7 @@ static int print_cmd_valid(int k, const vector pathvec,
        struct timespec until;
        struct path *pp;
 
-       if (k < 0 || k >= sizeof(vals))
+       if (k < 0 || k >= (sizeof(vals) / sizeof(int)))
                return 1;
 
        if (k == 2) {