As reported by John Sager, nft_set_attr_get_u32 can cause a segfault because nft_set_attr_get can return NULL. Check for a non-NULL pointer before dereferencing. This closes netfilter bugzilla #868. Signed-off-by: Phil Oester <kernel@xxxxxxxxxxxx>
diff --git a/src/set.c b/src/set.c index 74ec1e3..85f73cf 100644 --- a/src/set.c +++ b/src/set.c @@ -183,8 +183,8 @@ EXPORT_SYMBOL(nft_set_attr_get_str); uint32_t nft_set_attr_get_u32(struct nft_set *s, uint16_t attr) { - uint32_t val = *((uint32_t *)nft_set_attr_get(s, attr)); - return val; + const void *val = nft_set_attr_get(s, attr); + return val ? *(uint32_t *)val : 0; } EXPORT_SYMBOL(nft_set_attr_get_u32);