From: Phil Sutter Date: Thu, 11 Aug 2016 23:33:35 +0000 (+0200) Subject: expr/ct: prevent array index overrun in ctkey2str() X-Git-Tag: libnftnl-1.0.7~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cca54d5e9c3f436cd85bc55415c08bf671bfefe6;p=thirdparty%2Flibnftnl.git expr/ct: prevent array index overrun in ctkey2str() The array has NFT_CT_MAX fields, so indices must be less than that number. Fixes: 977b7a1dbe1bd ("ct: xml: use key names instead of numbers") Cc: Arturo Borrero Gonzalez Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/expr/ct.c b/src/expr/ct.c index 7d96df4e..1a53b49f 100644 --- a/src/expr/ct.c +++ b/src/expr/ct.c @@ -173,7 +173,7 @@ static const char *ctkey2str_array[NFT_CT_MAX] = { static const char *ctkey2str(uint32_t ctkey) { - if (ctkey > NFT_CT_MAX) + if (ctkey >= NFT_CT_MAX) return "unknown"; return ctkey2str_array[ctkey];