Re: [PATCH 1/2 libnftnl] utils: Fix out of bound access in nftnl_family2str

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/15/2016 01:03 PM, Pablo Neira Ayuso wrote:
On Mon, Aug 15, 2016 at 12:51:02PM +0200, Carlos Falgueras García wrote:
Checks array limits before access it and adds a missed translation.

Signed-off-by: Carlos Falgueras García <carlosfg@xxxxxxxxxx>
---
 src/utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/utils.c b/src/utils.c
index e2715a2..7264d1f 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -23,6 +23,7 @@
 #include <linux/netfilter/nf_tables.h>

 static const char *const nftnl_family_str[NFPROTO_NUMPROTO] = {
+	[NFPROTO_UNSPEC]	= "unknown",

You don't need this line above, right? I can mangle the patch here
before applying it.

Yes, sorry. Do you get rid of it or must I send another version?

 	[NFPROTO_INET]		= "inet",
 	[NFPROTO_IPV4]		= "ip",
 	[NFPROTO_ARP]		= "arp",
@@ -33,7 +34,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];
--
2.8.3

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux