]> git.ipfire.org Git - location/libloc.git/commitdiff
perl: Return nothing in case invalid data has been passed to libloc
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 28 Sep 2024 12:46:31 +0000 (14:46 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Mar 2025 11:24:34 +0000 (11:24 +0000)
The old croach approch instantly will stop the script if invalid data
will be passed to libloc and also will fail to proper execute the
testsuite.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/perl/Location.xs

index be6df14a24b9661086974d5c929229efe8115799..896cbcbe00f581976ba7358476389bd8a59c2109 100644 (file)
@@ -173,7 +173,7 @@ lookup_country_code(db, address)
                // Lookup network
                int err = loc_database_lookup_from_string(db, address, &network);
                if (err) {
-                       croak("Error fetching a network from the database\n");
+                       goto END;
                }
 
                // Extract the country code if we have found a network
@@ -184,6 +184,8 @@ lookup_country_code(db, address)
 
                        loc_network_unref(network);
                }
+
+               END:
        OUTPUT:
                RETVAL
 
@@ -213,7 +215,7 @@ lookup_network_has_flag(db, address, flag)
                // Lookup network
                int err = loc_database_lookup_from_string(db, address, &network);
                if (err) {
-                       croak("Error fetching a network from the database\n");
+                       goto END;
                }
 
                // Check if the network has the given flag
@@ -225,6 +227,7 @@ lookup_network_has_flag(db, address, flag)
                        loc_network_unref(network);
                }
 
+               END:
        OUTPUT:
                RETVAL
 
@@ -240,7 +243,7 @@ lookup_asn(db, address)
                // Lookup network
                int err = loc_database_lookup_from_string(db, address, &network);
                if (err) {
-                       croak("Error fetching a network from the database\n");
+                       goto END;
                }
 
                // Extract the ASN
@@ -252,6 +255,8 @@ lookup_asn(db, address)
 
                        loc_network_unref(network);
                }
+
+               END:
        OUTPUT:
                RETVAL