From 31df8f5d5924dbd92f88d2592b86ff949fefb6bd Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sat, 5 Mar 2022 10:01:24 +0100 Subject: [PATCH] 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 --- config/cfgroot/ipblocklist-functions.pl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/cfgroot/ipblocklist-functions.pl b/config/cfgroot/ipblocklist-functions.pl index 6da371a004..b6abb1befb 100644 --- a/config/cfgroot/ipblocklist-functions.pl +++ b/config/cfgroot/ipblocklist-functions.pl @@ -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); -- 2.39.5