]> git.ipfire.org Git - location/libloc.git/commitdiff
bogons: Don't consider a network legitimate without a country code
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 7 Mar 2022 11:33:53 +0000 (11:33 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 7 Mar 2022 11:33:53 +0000 (11:33 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/database.c

index 271bbd9f933109e3a517400055f50aba9dbe94a5..de4b56ef94c29bae32e6bf5855ce1da722a4ec30 100644 (file)
@@ -1430,6 +1430,19 @@ static int __loc_database_enumerator_next_bogon(
                if (!network)
                        goto FINISH;
 
+               const char* country_code = loc_network_get_country_code(network);
+
+               /*
+                       Skip anything that does not have a country code
+
+                       Even if a network is part of the routing table, and the database provides
+                       an ASN, this does not mean that this is a legitimate announcement.
+               */
+               if (country_code && !*country_code) {
+                       loc_network_unref(network);
+                       continue;
+               }
+
                // Determine the network family
                int family = loc_network_address_family(network);