]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
utils: Fix out of bound access in nftnl_family2str
authorCarlos Falgueras García <carlosfg@riseup.net>
Mon, 15 Aug 2016 10:51:02 +0000 (12:51 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 15 Aug 2016 11:47:56 +0000 (13:47 +0200)
Checks array limits before access it and adds a missed translation.

Signed-off-by: Carlos Falgueras García <carlosfg@riseup.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/utils.c

index e2715a216f18521b1a0e50455b04c39ada6c7eb7..f0f54677d213e4aa47f2fc8c9498cc57b252c9f1 100644 (file)
@@ -33,7 +33,7 @@ static const char *const nftnl_family_str[NFPROTO_NUMPROTO] = {
 
 const char *nftnl_family2str(uint32_t family)
 {
-       if (nftnl_family_str[family] == NULL)
+       if (family >= NFPROTO_NUMPROTO || !nftnl_family_str[family])
                return "unknown";
 
        return nftnl_family_str[family];