From 2e544984f04f7dd2bd764c000f2d61a04e1489d7 Mon Sep 17 00:00:00 2001 From: Micah Snyder Date: Wed, 30 Oct 2024 17:45:36 -0400 Subject: [PATCH] Freshclam, Sigtool, Clamconf: fix database line count if has empty lines Fixes: https://github.com/Cisco-Talos/clamav/issues/1390 --- common/misc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/misc.c b/common/misc.c index fa61929d5d..d3b755c729 100644 --- a/common/misc.c +++ b/common/misc.c @@ -479,7 +479,15 @@ unsigned int countlines(const char *filename) return 0; while (fgets(buff, sizeof(buff), fh)) { + // ignore comments if (buff[0] == '#') continue; + + // ignore empty lines in CR/LF format + if (buff[0] == '\r' && buff[1] == '\n') continue; + + // ignore empty lines in LF format + if (buff[0] == '\n') continue; + lines++; }