Skip to content

Commit 0469022

Browse files
committed
ipv4defrag: fix segfault
1 parent dc8a17c commit 0469022

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/ipv4defrag.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,17 @@ unsigned int ntoh_ipv4_get_tuple4 ( struct ip *ip , pntoh_ipv4_tuple4_t tuple )
9090

9191
unsigned short ipv4_equal_tuple ( void *a , void *b )
9292
{
93-
unsigned short ret = 0;
94-
95-
if ( ! memcmp ( a , (void*)&((pntoh_ipv4_flow_t)b)->ident , sizeof ( ntoh_ipv4_tuple4_t) ) )
96-
ret++;
97-
98-
return ret;
93+
pntoh_ipv4_tuple4_t tuple_a = a;
94+
pntoh_ipv4_tuple4_t tuple_b = (void*)&((pntoh_ipv4_flow_t)b)->ident;
95+
if (
96+
(tuple_a->source == tuple_b->source) &&
97+
(tuple_a->destination == tuple_b->destination) &&
98+
(tuple_a->protocol == tuple_b->protocol) &&
99+
(tuple_a->id == tuple_b->id)
100+
) {
101+
return 1;
102+
}
103+
return 0;
99104
}
100105

101106
pntoh_ipv4_flow_t ntoh_ipv4_find_flow ( pntoh_ipv4_session_t session , pntoh_ipv4_tuple4_t tuple4 )
@@ -559,6 +564,7 @@ inline static void __ipv4_free_session ( pntoh_ipv4_session_t session )
559564

560565
while ( ( first = htable_first ( session->flows ) ) != 0 )
561566
{
567+
item = htable_find(session->flows, first, NULL);
562568
lock_access ( &item->lock );
563569
__ipv4_free_flow ( session , &item , NTOH_REASON_EXIT );
564570
}

0 commit comments

Comments
 (0)