From: Eric Leblond Date: Wed, 28 Mar 2012 15:19:05 +0000 (+0200) Subject: pcap: fix "work by luck" code. X-Git-Tag: suricata-1.3beta1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91f42b6f41037bb649f0c37eee8db3aa906dc6f6;p=thirdparty%2Fsuricata.git pcap: fix "work by luck" code. --- diff --git a/src/source-pcap.c b/src/source-pcap.c index 4d3f59a876..b8bd9c1a46 100644 --- a/src/source-pcap.c +++ b/src/source-pcap.c @@ -472,17 +472,17 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) { SCReturnInt(TM_ECODE_FAILED); } - SCLogInfo("using interface %s", (char *)initdata); - if(strlen(initdata)>PCAP_IFACE_NAME_LENGTH) { + SCLogInfo("using interface %s", pcapconfig->iface); + if (strlen(pcapconfig->iface) > PCAP_IFACE_NAME_LENGTH) { SCFree(ptv); /* Dereference config */ pcapconfig->DerefFunc(pcapconfig); SCReturnInt(TM_ECODE_FAILED); } - strlcpy(ptv->iface, (char *)initdata, PCAP_IFACE_NAME_LENGTH); + strlcpy(ptv->iface, pcapconfig->iface, PCAP_IFACE_NAME_LENGTH); char errbuf[PCAP_ERRBUF_SIZE] = ""; - ptv->pcap_handle = pcap_open_live((char *)initdata, LIBPCAP_SNAPLEN, + ptv->pcap_handle = pcap_open_live(ptv->iface, LIBPCAP_SNAPLEN, LIBPCAP_PROMISC, LIBPCAP_COPYWAIT, errbuf); if (ptv->pcap_handle == NULL) { SCLogError(SC_ERR_PCAP_OPEN_LIVE, "Problem creating pcap handler for live mode, error %s", errbuf);