Skip to contentSkip to conversation

Recent Match - Possible memory leaks + Possible buffer overflow with strncpy()

PATCH New Stephane Ouellette 1 participant 1 message Oct 29, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Recent Match - Possible memory leaks + Possible buffer overflow with strncpy()

Folks,

the attached patch fixes for the recent match two issues:

1- using strncpy() does not garantee that the destination string will be NULL-terminated

2- If a vmalloc() fails, the previously allocated memory blocks are not freed.

Enjoy !

include/linux/netfilter_ipv4/ipt_recent.h +3 -1
diff -aruN linux-2.4.20-pre10-ac2/include/linux/netfilter_ipv4/ipt_recent.h linux-2.4.20-pre10-ac2-new/include/linux/netfilter_ipv4/ipt_recent.h
@@ -1,6 +1,8 @@
 #ifndef _IPT_RECENT_H
 #define _IPT_RECENT_H
 
+#define NAME_LEN  200
+
 const static int IPT_RECENT_CHECK = 1;
 const static int IPT_RECENT_SET = 2;
 const static int IPT_RECENT_UPDATE = 4;
@@ -15,7 +17,7 @@
 	u_int32_t   hit_count;
 	u_int8_t    check_set;
 	u_int8_t    invert;
-	char        name[200];
+	char        name[NAME_LEN];
 	u_int8_t    side;
 };
 
net/ipv4/netfilter/ipt_recent.c +36 -20

135 lines not on this page · raw message