PUD: check type after length in downlink path
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 19 Apr 2012 09:55:53 +0000 (11:55 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 19 Apr 2012 10:08:23 +0000 (12:08 +0200)
So that we just skip over unsupported downlink messages

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/pud.c

index ab7f6af..bb6eea2 100644 (file)
@@ -185,12 +185,6 @@ static void packetReceivedFromDownlink(int skfd, void *data __attribute__ ((unus
                        union olsr_message * olsrMessage;
 
                        type = getUplinkMessageType(&msg->header);
-                       if (type != POSITION) {
-                               pudError(false, "Received wrong type (%d) in %s,"
-                                               " ignoring the rest of the messages.", type, __func__);
-                               return;
-                       }
-
                        olsrMessageLength = getUplinkMessageLength(&msg->header);
                        uplinkMessageLength = olsrMessageLength + sizeof(UplinkHeader);
 
@@ -203,6 +197,12 @@ static void packetReceivedFromDownlink(int skfd, void *data __attribute__ ((unus
 
                        rxIndex += uplinkMessageLength;
 
+                       if (type != POSITION) {
+                               pudError(false, "Received wrong type (%d) in %s,"
+                                               " ignoring message.", type, __func__);
+                               continue;
+                       }
+
                        ipv6 = getUplinkMessageIPv6(&msg->header);
                        if (unlikely(ipv6 && (olsr_cnf->ip_version != AF_INET6))) {
                                pudError(false, "Received wrong IPv6 status (%s) in %s,"