pool: Proper handling of address family when adding addresses.
authorTobias Brunner <tobias@strongswan.org>
Tue, 19 Apr 2011 10:43:00 +0000 (12:43 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 19 Apr 2011 11:48:50 +0000 (13:48 +0200)
src/libhydra/plugins/attr_sql/pool.c

index 157986d..0ef41a7 100644 (file)
@@ -407,7 +407,8 @@ static bool add_address(u_int pool_id, char *address_str, int *family)
                fprintf(stderr, "invalid address '%s'.\n", address_str);
                return FALSE;
        }
-       if (family && *family && *family != address->get_family(address))
+       if (family && *family != AF_UNSPEC &&
+               *family != address->get_family(address))
        {
                fprintf(stderr, "invalid address family '%s'.\n", address_str);
                return FALSE;
@@ -423,7 +424,10 @@ static bool add_address(u_int pool_id, char *address_str, int *family)
                fprintf(stderr, "inserting address '%s' failed.\n", address_str);
                return FALSE;
        }
-       *family = address->get_family(address);
+       if (family)
+       {
+               *family = address->get_family(address);
+       }
        address->destroy(address);
 
        return TRUE;