Skip to contentSkip to conversation

iptables segfault on -D

PATCH In review Phil Oester 2 participants 2 messages Feb 4, 2005 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iptables segfault on -D

Using latest 1.3.0-rc1 snapshot, a rule delete causes a segfault:

# iptables -A foo -p tcp --dport 1234   
# iptables -D foo -p tcp --dport 1234
Segmentation fault

Problem is caused by a superfluous memset which memsets a greater- than-malloced area. Patch below.

Phil

libiptc/libiptc.c +0 -1
@@ -2047,7 +2047,6 @@
 
 	counterlen = sizeof(STRUCT_COUNTERS_INFO)
 			+ sizeof(STRUCT_COUNTERS) * new_number;
-	memset(repl, 0, sizeof(*repl) + (*handle)->entries->size);
 
 	/* These are the old counters we will get from kernel */
 	repl->counters = malloc(sizeof(STRUCT_COUNTERS)
#1 lore raw
Quoted 8 lines · Phil Oester

Using latest 1.3.0-rc1 snapshot, a rule delete causes a segfault:

# iptables -A foo -p tcp --dport 1234   
# iptables -D foo -p tcp --dport 1234
Segmentation fault

Problem is caused by a superfluous memset which memsets a greater- than-malloced area. Patch below.

Yes this memset() is bogus, patch applied. And I removed the other memset() that was added at the same time in order to stop valgrind from complaining, that needs more investigation as to why valgrind is complaining.

Thanks

Signature · 1 line
/Martin