diff options
-rw-r--r-- | src/lib/protocols/http.c | 2 | ||||
-rw-r--r-- | src/lib/protocols/ssh.c | 2 | ||||
-rwxr-xr-x | tests/vagrind_test.sh | 33 |
3 files changed, 35 insertions, 2 deletions
diff --git a/src/lib/protocols/http.c b/src/lib/protocols/http.c index 4382879d0..70ca0c389 100644 --- a/src/lib/protocols/http.c +++ b/src/lib/protocols/http.c @@ -484,7 +484,7 @@ static u_int16_t http_request_url_offset(struct ndpi_detection_module_struct *nd packet->payload_packet_len); /* Check first char */ - if(!strchr(http_fs,packet->payload[0])) return 0; + if(!packet->payload_packet_len || !strchr(http_fs,packet->payload[0])) return 0; /** FIRST PAYLOAD PACKET FROM CLIENT **/ diff --git a/src/lib/protocols/ssh.c b/src/lib/protocols/ssh.c index 5bdf78959..068d2c345 100644 --- a/src/lib/protocols/ssh.c +++ b/src/lib/protocols/ssh.c @@ -296,7 +296,7 @@ static void ndpi_search_ssh_tcp(struct ndpi_detection_module_struct *ndpi_struct flow->l4.tcp.ssh_stage = 3; return; } - } else { + } else if(packet->payload_packet_len > 5) { u_int8_t msgcode = *(packet->payload + 5); ndpi_MD5_CTX ctx; diff --git a/tests/vagrind_test.sh b/tests/vagrind_test.sh new file mode 100755 index 000000000..aa04dab40 --- /dev/null +++ b/tests/vagrind_test.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +READER="valgrind -q --leak-check=full ../example/ndpiReader -p ../example/protos.txt -c ../example/categories.txt" + +RC=0 +PCAPS=`cd pcap; /bin/ls *.pcap` + +check_results() { + for f in $PCAPS; do + CMD="$READER -q -i pcap/$f > /tmp/reader.out" + $CMD + NUM_DIFF=0 + + if [ -f /tmp/reader.out ]; then + NUM_DIFF=`wc -l /tmp/reader.out` + fi + + if [ $NUM_DIFF -eq 0 ]; then + printf "%-32s\tOK\n" "$f" + else + printf "%-32s\tERROR\n" "$f" + echo "$CMD" + cat /tmp/reader.out + RC=1 + fi + + /bin/rm -f /tmp/reader.out + done +} + +check_results + +exit $RC |