1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
commit 8fc250f1d3a3b1a7a9451edd2d3750e92d0b3605
Author: Romain Francoise <romain@rfr.io>
Date: Sat Nov 20 23:57:50 2021 +0100
Fix various build warnings and minor problems
diff --git a/ngrep.c b/ngrep.c
index dcf05551ad..7c0b6c7294 100644
--- a/ngrep.c
+++ b/ngrep.c
@@ -98,6 +98,10 @@
#include <regex.h>
#endif
+#if USE_TCPKILL
+#include "tcpkill.h"
+#endif
+
#include "ngrep.h"
@@ -1500,8 +1504,6 @@ void version(void) {
void clean_exit(int32_t sig) {
- struct pcap_stat s;
-
signal(SIGINT, SIG_IGN);
signal(SIGABRT, SIG_IGN);
#if !defined(_WIN32)
@@ -1529,6 +1531,7 @@ void clean_exit(int32_t sig) {
if (quiet < 1 && sig >= 0 && !read_file)
printf("%u received, %u matched\n", seen_frames, matches);
+ pcap_freecode(&pcapfilter);
if (pd) pcap_close(pd);
if (pd_dumppcap) pcap_close(pd_dumppcap);
if (pd_dump) pcap_dump_close(pd_dump);
diff --git a/tcpkill.c b/tcpkill.c
index 5388ec5fab..e46b8fa8ca 100644
--- a/tcpkill.c
+++ b/tcpkill.c
@@ -14,6 +14,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <err.h>
#include <libnet.h>
#include <pcap.h>
@@ -27,11 +28,10 @@ tcpkill_kill(const struct pcap_pkthdr *pcap, const u_char *pkt,
{
struct libnet_ipv4_hdr *ip;
struct libnet_tcp_hdr *tcp;
- u_char ctext[64];
- uint32_t seq, win, i, len;
+ char ctext[64];
+ uint32_t seq, win, i;
pkt += pcap_off;
- len = pcap->caplen - pcap_off;
ip = (struct libnet_ipv4_hdr *)pkt;
if (ip->ip_p != IPPROTO_TCP)
@@ -67,7 +67,7 @@ tcpkill_kill(const struct pcap_pkthdr *pcap, const u_char *pkt,
if (libnet_write(l) < 0)
warn("write");
- fprintf(stderr, "%s R %lu:%lu(0) win 0\n", ctext, seq, seq);
+ fprintf(stderr, "%s R %u:%u(0) win 0\n", ctext, seq, seq);
}
}
|