netfilter: ipset: fix uninitialized variable bug
Subsystems (3)
PATCH 1/1 netfilter: ipset: fix uninitialized variable bug
This condition doesn't work because "port_to" is not initialized until the next line. Move the condition down.
Fixes 7fb6c63025ff ("netfilter: ipset: Limit the maximal range of consecutive elements to add/delete")
Signed-off-by Dan Carpenter <[email protected]>
--- net/netfilter/ipset/ip_set_hash_ipportnet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/ipset/ip_set_hash_ipportnet.c +3 -3
@@ -246,9 +246,6 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],ip_set_mask_from_to (ip, ip_to, cidr); } -if (((u64 )ip_to - ip +1 )*(port_to - port +1 ) >IPSET_MAX_RANGE ) -return -ERANGE ; - port_to = port =ntohs (e.port);if (tb[IPSET_ATTR_PORT_TO ]) { port_to =ip_set_get_h16 (tb[IPSET_ATTR_PORT_TO ]);
@@ -256,6 +253,9 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],swap (port, port_to); } +if (((u64 )ip_to - ip +1 )*(port_to - port +1 ) >IPSET_MAX_RANGE ) +return -ERANGE ; + ip2_to = ip2_from;if (tb[IPSET_ATTR_IP2_TO ]) { ret =ip_set_get_hostipaddr4 (tb[IPSET_ATTR_IP2_TO ], &ip2_to);
Signature · 1 line
2.20.1
Hi Dan,
Quoted 2 lines · Dan Carpenter
This condition doesn't work because "
port_to" is not initialized until the next line. Move the condition down.
You are right - Nathan Chancellor already sent the same fix and I acked it. Thanks!
Best regards,
Jozsef
Quoted 34 lines
Fixes 7fb6c63025ff ("netfilter: ipset: Limit the maximal range of consecutive elements to add/delete")Signed-off-by Dan Carpenter <[email protected]>--- net/netfilter/ipset/ip_set_hash_ipportnet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)net/netfilter/ipset/ip_set_hash_ipportnet.c +3
-3@@ -246,9 +246,6 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],ip_set_mask_from_to (ip, ip_to, cidr); } -if (((u64 )ip_to - ip +1 )*(port_to - port +1 ) >IPSET_MAX_RANGE ) -return -ERANGE ; - port_to = port =ntohs (e.port);if (tb[IPSET_ATTR_PORT_TO ]) { port_to =ip_set_get_h16 (tb[IPSET_ATTR_PORT_TO ]);@@ -256,6 +253,9 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],swap (port, port_to); } +if (((u64 )ip_to - ip +1 )*(port_to - port +1 ) >IPSET_MAX_RANGE ) +return -ERANGE ; + ip2_to = ip2_from;if (tb[IPSET_ATTR_IP2_TO ]) { ret =ip_set_get_hostipaddr4 (tb[IPSET_ATTR_IP2_TO ], &ip2_to);Signature · 1 line
2.20.1
-
E-mail : [email protected], [email protected] PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics
H-1525 Budapest 114, POB. 49, Hungary