Skip to contentSkip to conversation

utils: nfsynproxy: fix error while compiling the BPF filter

PATCH New Pablo Neira Ayuso 1 participant 1 message Nov 18, 2013 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH v2 1/1 utils: nfsynproxy: fix error while compiling the BPF filter

Fix the following error while running nfsynproxy here:

pcap_compile: not-yet-activated pcap_t passed to pcap_compile

According to what I have read, we have to compile the filter once it has been activated.

---
v2: fix incorrect error path in v1

 utils/nfsynproxy.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
utils/nfsynproxy.c +8 -8
index 9b6de93..baedc92 100644
@@ -109,20 +109,20 @@ static void probe_host(const char *host)
 		goto err2;
 	}
 
-	if (pcap_compile(ph, &fp, "src host 127.0.0.1 and tcp and src port 80",
-			 1, PCAP_NETMASK_UNKNOWN) == -1) {
-		pcap_perror(ph, "pcap_compile");
-		goto err2;
-	}
-
 	if (pcap_setfilter(ph, &fp) == -1) {
 		pcap_perror(ph, "pcap_setfilter");
-		goto err3;
+		goto err2;
 	}
 
 	if (pcap_activate(ph) != 0) {
 		pcap_perror(ph, "pcap_activate");
-		goto err3;
+		goto err2;
+	}
+
+	if (pcap_compile(ph, &fp, "src host 127.0.0.1 and tcp and src port 80",
+			 1, PCAP_NETMASK_UNKNOWN) == -1) {
+		pcap_perror(ph, "pcap_compile");
+		goto err2;
 	}
 
 	fd = socket(AF_INET, SOCK_STREAM, 0);
Signature · 1 line
1.7.10.4