@@ -222,6 +222,7 @@ void extcap_config() {
222222}
223223
224224void extcap_capture () {
225+ pcap_t * pcap_dead = NULL ;
225226 pcap_dumper_t * dumper = NULL ;
226227 u_char * buffer_p = NULL ;
227228 struct pfring_pkthdr hdr ;
@@ -233,18 +234,33 @@ void extcap_capture() {
233234 return ;
234235 }
235236
236- if ((dumper = pcap_dump_open (pcap_open_dead (DLT_EN10MB , 16384 /* MTU */ ), extcap_capture_fifo )) == NULL ) {
237+ if ((pcap_dead = pcap_open_dead (DLT_EN10MB , 16384 /* MTU */ )) == NULL ) {
238+ fprintf (stderr , "Unable to open the dead pcap handle" );
239+ free (nbpf );
240+ return ;
241+ }
242+
243+ if ((dumper = pcap_dump_open (pcap_dead , extcap_capture_fifo )) == NULL ) {
237244 fprintf (stderr , "Unable to open the pcap dumper on %s" , extcap_capture_fifo );
245+ pcap_close (pcap_dead );
246+ free (nbpf );
238247 return ;
239248 }
240-
249+
241250 if ((pd = pfring_open (ntopdump_name , 1520 , PF_RING_PROMISC | PF_RING_HW_TIMESTAMP )) == NULL ) {
242251 fprintf (stderr , "Unable to open interface %s" , ntopdump_name );
252+ pcap_dump_close (dumper );
253+ pcap_close (pcap_dead );
254+ free (nbpf );
243255 return ;
244256 }
245257
246258 if ((signal (SIGINT , sigproc ) == SIG_ERR ) || (signal (SIGTERM , sigproc ) == SIG_ERR ) || (signal (SIGQUIT , sigproc ) == SIG_ERR )) {
247259 fprintf (stderr , "Unable to install SIGINT/SIGTERM signal handler" );
260+ pfring_close (pd );
261+ pcap_dump_close (dumper );
262+ pcap_close (pcap_dead );
263+ free (nbpf );
248264 return ;
249265 }
250266
@@ -286,9 +302,10 @@ void extcap_capture() {
286302 }
287303
288304 pcap_dump_close (dumper );
305+ pcap_close (pcap_dead );
289306 pfring_close (pd );
290307 free (nbpf );
291-
308+
292309}
293310
294311int extcap_print_help () {
0 commit comments