diff mbox series

[iptables,1/5] libxtables: Fix potential array overrun in xtables_option_parse()

Message ID 20180910213517.12160-2-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series Fix for bugs indicated by covscan | expand

Commit Message

Phil Sutter Sept. 10, 2018, 9:35 p.m. UTC
If entry->type is to be used as array index, it needs to be at max one
less than that array's size.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 libxtables/xtoptions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libxtables/xtoptions.c b/libxtables/xtoptions.c
index ba3128bdbeb6b..326febd50dc90 100644
--- a/libxtables/xtoptions.c
+++ b/libxtables/xtoptions.c
@@ -844,7 +844,7 @@  void xtables_option_parse(struct xt_option_call *cb)
 	 * a *RC option type.
 	 */
 	cb->nvals = 1;
-	if (entry->type <= ARRAY_SIZE(xtopt_subparse) &&
+	if (entry->type < ARRAY_SIZE(xtopt_subparse) &&
 	    xtopt_subparse[entry->type] != NULL)
 		xtopt_subparse[entry->type](cb);
 	/* Exclusion with other flags tested later in finalize. */