mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
ipblocklist-functions.pl: Abort and return code if a list is empty or
not parse-able. In case the downloaded list is empty or the parser is not able to parse it properly, the download_and_create_blocklist() function now exits and will return "empty_list" as new error code. Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
@@ -91,6 +91,8 @@ sub get_ipset_db_file($) {
|
||||
## nothing - On success
|
||||
## not_modified - In case the servers responds with "Not modified" (304)
|
||||
## dl_error - If the requested blocklist could not be downloaded.
|
||||
## empty_list - The downloaded blocklist is empty, or the parser was not able to parse
|
||||
## it correctly.
|
||||
#
|
||||
sub download_and_create_blocklist($) {
|
||||
my ($list) = @_;
|
||||
@@ -218,6 +220,13 @@ sub download_and_create_blocklist($) {
|
||||
push(@blocklist, $address);
|
||||
}
|
||||
|
||||
# Check if the content could be parsed correctly and the blocklist
|
||||
# contains at least one item.
|
||||
unless(@blocklist) {
|
||||
# No entries - exit and return "empty_list".
|
||||
return "empty_list";
|
||||
}
|
||||
|
||||
# Get amount of entries in the blocklist array.
|
||||
my $list_entries = scalar(@blocklist);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user