PUD: cfg: do max count check on rxAllowedSourceIpAddressesCount earlier
authorFerry Huberts <ferry.huberts@pelagic.nl>
Sun, 3 Jun 2012 09:42:45 +0000 (11:42 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 7 Jun 2012 22:30:01 +0000 (00:30 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/configuration.c

index 2be36be..4789ba8 100644 (file)
@@ -594,6 +594,12 @@ int addRxAllowedSourceIpAddress(const char *value, void *data __attribute__ ((un
 
        assert (value != NULL);
 
+       if (rxAllowedSourceIpAddressesCount >= PUD_RX_ALLOWED_SOURCE_IP_MAX) {
+               pudError(false, "Can't configure more than %u allowed source IP"
+                       " addresses", PUD_RX_ALLOWED_SOURCE_IP_MAX);
+               return true;
+       }
+
        memset(&addr, 0, sizeof(addr));
 
        addr.sa_family = olsr_cnf->ip_version;
@@ -606,12 +612,6 @@ int addRxAllowedSourceIpAddress(const char *value, void *data __attribute__ ((un
        }
 
        if ((rxAllowedSourceIpAddressesCount == 0) || !isRxAllowedSourceIpAddress(&addr)) {
-               if (rxAllowedSourceIpAddressesCount >= PUD_RX_ALLOWED_SOURCE_IP_MAX) {
-                       pudError(false, "Can't configure more than %u allowed source IP"
-                               " addresses", PUD_RX_ALLOWED_SOURCE_IP_MAX);
-                       return true;
-               }
-
                rxAllowedSourceIpAddresses[rxAllowedSourceIpAddressesCount] = addr;
                rxAllowedSourceIpAddressesCount++;
        }