From 5025b70fae9ab2d79deac9e08d806a85c339ddbe Mon Sep 17 00:00:00 2001 From: Håkon Nessjøen Date: Sun, 3 Oct 2010 03:46:35 +0200 Subject: Fix invalid counter sizes which would break connection after 65535 bytes of data in one direction --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 545c317..cea231d 100644 --- a/main.c +++ b/main.c @@ -40,8 +40,8 @@ int sockfd; int deviceIndex; -int outcounter = 0; -int incounter = 0; +unsigned int outcounter = 0; +unsigned int incounter = 0; int sessionkey = 0; int running = 1; @@ -152,7 +152,7 @@ void handlePacket(unsigned char *data, int data_len) { /* Accept first packet, and all packets greater than incounter, and if counter has wrapped around. */ - if (incounter == 0 || pkthdr.counter > incounter || incounter - pkthdr.counter > 32768) { + if (incounter == 0 || pkthdr.counter > incounter || (incounter - pkthdr.counter) > 65535) { incounter = pkthdr.counter; } else { /* Ignore double or old packets */ -- cgit v1.2.3