]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
object: fix crash when object ops is null
authorFlorian Westphal <fw@strlen.de>
Sun, 19 Feb 2017 21:59:42 +0000 (22:59 +0100)
committerFlorian Westphal <fw@strlen.de>
Mon, 27 Feb 2017 16:10:53 +0000 (17:10 +0100)
when debugging nft with invalid object type (during development),
this will crash here with null deref.  Print (unknown) instead
if obj->ops is null.

Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/object.c

index 62fa48afa2a1869681aa2b1ec54fe633fe42b6b7..773eff6a5a1817d84681e5a148f9e559dbf3a9dd 100644 (file)
@@ -396,10 +396,11 @@ static int nftnl_obj_snprintf_dflt(char *buf, size_t size,
                                   const struct nftnl_obj *obj,
                                   uint32_t type, uint32_t flags)
 {
+       const char *name = obj->ops ? obj->ops->name : "(unknown)";
        int ret, len = size, offset = 0;
 
        ret = snprintf(buf, size, "table %s name %s use %u [ %s ",
-                      obj->table, obj->name, obj->use, obj->ops->name);
+                      obj->table, obj->name, obj->use, name);
        SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
        if (obj->ops) {