]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
src: Fix for reading garbage in nftnl_chain getters
authorPhil Sutter <phil@nwl.cc>
Fri, 14 Feb 2020 17:20:29 +0000 (18:20 +0100)
committerPhil Sutter <phil@nwl.cc>
Wed, 19 Feb 2020 10:45:44 +0000 (11:45 +0100)
In {s,u}{32,64} type getters nftnl_assert() is called to make sure
returned data length matches expectations. Therefore all attributes must
set data_len, which NFTNL_CHAIN_DEVICES didn't.

While being at it, do the same change for NFTNL_FLOWTABLE_DEVICES as
well to make code a bit more consistent although the problem was fixed
for flowtables with commit f8eed54150fd4 ("flowtable: Fix for reading
garbage") already (but in the other direction).

Fixes: e3ac19b5ec162 ("chain: multi-device support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/chain.c
src/flowtable.c

index b4066e4d4e888f14e4b15d7ae81ee0ac10766bfe..94a9e43a17548bbfbfc89ad48697ae2530c8d283 100644 (file)
@@ -364,6 +364,7 @@ const void *nftnl_chain_get_data(const struct nftnl_chain *c, uint16_t attr,
                *data_len = strlen(c->dev) + 1;
                return c->dev;
        case NFTNL_CHAIN_DEVICES:
+               *data_len = 0;
                return &c->dev_array[0];
        }
        return NULL;
index 1e235d0ba50fa5a81ea6ebc2a5c4d7059e715510..635322d7fa56305f723fed6feb8521d734181db2 100644 (file)
@@ -230,6 +230,7 @@ const void *nftnl_flowtable_get_data(const struct nftnl_flowtable *c,
                *data_len = sizeof(int32_t);
                return &c->family;
        case NFTNL_FLOWTABLE_DEVICES:
+               *data_len = 0;
                return &c->dev_array[0];
        case NFTNL_FLOWTABLE_SIZE:
                *data_len = sizeof(int32_t);