]> git.ipfire.org Git - dbl.git/commitdiff
dnsbl: analyze: Don't divide by zero when a source is empty
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Dec 2025 12:44:01 +0000 (12:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Dec 2025 12:44:01 +0000 (12:44 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/dnsbl.in

index bcd4596f4cb156ee04c3ab2a99c79b2b53d91499..05ff8007d336356d848bae00767f4296569dd137 100644 (file)
@@ -454,8 +454,16 @@ class CLI(object):
                                        columns.append("")
                                        continue
 
+                               # Determine the length of the source
+                               length = len(source)
+
+                               # Skip if the source is empty
+                               if not length:
+                                       columns.append("")
+                                       continue
+
                                columns.append(
-                                       "%.2f%%" % (value / len(source) * 100),
+                                       "%.2f%%" % (value / length * 100),
                                )
 
                        # Add a row to the table