netfilter: ipset: off by one in ip_set_nfnl_get_byindex()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 21 Oct 2014 08:28:12 +0000 (11:28 +0300)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 22 Oct 2014 12:12:50 +0000 (14:12 +0200)
The ->ip_set_list[] array is initialized in ip_set_net_init() and it
has ->ip_set_max elements so this check should be >= instead of >
otherwise we are off by one.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/ipset/ip_set_core.c

index 912e5a05b79dbdc2de8aaa3729e08af01888dc4e..86f9d76b1464b1b0d5e8b5fc9f9c0c129713bd57 100644 (file)
@@ -659,7 +659,7 @@ ip_set_nfnl_get_byindex(struct net *net, ip_set_id_t index)
        struct ip_set *set;
        struct ip_set_net *inst = ip_set_pernet(net);
 
-       if (index > inst->ip_set_max)
+       if (index >= inst->ip_set_max)
                return IPSET_INVALID_ID;
 
        nfnl_lock(NFNL_SUBSYS_IPSET);