Commit 4310842b authored by Olav Kvittem's avatar Olav Kvittem

0.9.4 protect crude against small packets from non-rudes

parent 3eb53ef7
...@@ -1018,6 +1018,7 @@ static int rec_to_file(unsigned short port, unsigned long limit) ...@@ -1018,6 +1018,7 @@ static int rec_to_file(unsigned short port, unsigned long limit)
struct pcap_pkthdr *header; struct pcap_pkthdr *header;
const u_char *packet; const u_char *packet;
int result; int result;
int nsmallpkts=0;
while(1) while(1)
{ {
...@@ -1036,6 +1037,8 @@ static int rec_to_file(unsigned short port, unsigned long limit) ...@@ -1036,6 +1037,8 @@ static int rec_to_file(unsigned short port, unsigned long limit)
if(rec_bytes <= 0) if(rec_bytes <= 0)
{ {
RUDEBUG1("crude: error when receiving packet: %s\n",strerror(errno)); RUDEBUG1("crude: error when receiving packet: %s\n",strerror(errno));
} else if (rec_bytes < sizeof(struct udp_data)){ // not a rude packet
nsmallpkts++;
} }
else else
{ {
...@@ -1247,6 +1250,7 @@ static int rec_n_print(unsigned short port, unsigned long limit) ...@@ -1247,6 +1250,7 @@ static int rec_n_print(unsigned short port, unsigned long limit)
int ttl = 64; int ttl = 64;
int hoplimit = 64; int hoplimit = 64;
int received_ttl; int received_ttl;
int nsmallpkts=0;
struct sockaddr_storage src_addr; struct sockaddr_storage src_addr;
struct msghdr msgh; struct msghdr msgh;
struct iovec iov; struct iovec iov;
...@@ -1288,8 +1292,9 @@ static int rec_n_print(unsigned short port, unsigned long limit) ...@@ -1288,8 +1292,9 @@ static int rec_n_print(unsigned short port, unsigned long limit)
if(rec_bytes <= 0) if(rec_bytes <= 0)
{ {
RUDEBUG1("crude: error when receiving packet: %s\n",strerror(errno)); RUDEBUG1("crude: error when receiving packet: %s\n",strerror(errno));
} } else if (rec_bytes < sizeof(struct udp_data)){ // not a rude/crude packet
else nsmallpkts++;
} else
{ {
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
int *ttlptr; int *ttlptr;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#define PMAXSIZE 32768 /* Maximum accepted UDP-data field/packet size */ #define PMAXSIZE 32768 /* Maximum accepted UDP-data field/packet size */
#define MINDURAT 0.001 /* Minimum allowed flow duration in seconds (float) */ #define MINDURAT 0.001 /* Minimum allowed flow duration in seconds (float) */
#define VERSION "0.9.3" #define VERSION "0.9.4"
/* /*
* Enumeration definition for different (known) flow types * Enumeration definition for different (known) flow types
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment