netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nft: nft_set_attr_get_u32 null pointer deref
@ 2013-10-25 16:55 Phil Oester
  2013-10-27 20:34 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Oester @ 2013-10-25 16:55 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo

[-- Attachment #1: Type: text/plain, Size: 252 bytes --]

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@linuxace.com>


[-- Attachment #2: patch-get_u32 --]
[-- Type: text/plain, Size: 424 bytes --]

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);
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-27 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-25 16:55 [PATCH] nft: nft_set_attr_get_u32 null pointer deref Phil Oester
2013-10-27 20:34 ` Pablo Neira Ayuso
2013-10-27 23:29   ` Phil Oester

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).