diff --git a/clamav-Fix-int64-overflow-check.patch b/clamav-Fix-int64-overflow-check.patch new file mode 100644 index 0000000000000000000000000000000000000000..a27f398357a370307503de88ca35d7b70f90f4ae --- /dev/null +++ b/clamav-Fix-int64-overflow-check.patch @@ -0,0 +1,41 @@ +From 38622da97fb6fcb2d43d5676ac75cb5ac7896359 Mon Sep 17 00:00:00 2001 +From: lutianxiong +Date: Tue, 16 Jun 2020 11:15:10 +0800 +Subject: [PATCH] Fix int64 overflow check + +Overflow check "(value >> 32) * 10 < INT32_MAX" may not work in +certain conditions, e.g. value is 0xcccccccdbcdc9cc + +Note: This fixes oss-fuzz bug 16117. +--- + libclamav/htmlnorm.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/libclamav/htmlnorm.c b/libclamav/htmlnorm.c +index d0be15b..4ac4948 100644 +--- a/libclamav/htmlnorm.c ++++ b/libclamav/htmlnorm.c +@@ -1459,9 +1459,9 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag + next_state = HTML_BAD_STATE; + ptr++; + } else if (isdigit(*ptr) || (hex && isxdigit(*ptr))) { +- if (hex && (value >> 32) * 16 < INT32_MAX) { ++ if (hex && value < INT64_MAX / 16) { + value *= 16; +- } else if ((value >> 32) * 10 < INT32_MAX) { ++ } else if (value < INT64_MAX / 10) { + value *= 10; + } else { + html_output_c(file_buff_o2, value); +@@ -1727,7 +1727,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag + state = HTML_RFC2397_DATA; + break; + case HTML_ESCAPE_CHAR: +- if ((value >> 32) * 16 < INT32_MAX) { ++ if (value < INT64_MAX / 16) { + value *= 16; + } else { + state = next_state; +-- +2.23.0 + diff --git a/clamav.spec b/clamav.spec index 941b154732c0a521f20ff6b7f8204b3644e7d0c8..b01e442abfe4d6abf5d8bf40f8c952e02d5b010a 100644 --- a/clamav.spec +++ b/clamav.spec @@ -1,7 +1,7 @@ Name: clamav Summary: End-user tools for the Clam Antivirus scanner Version: 0.101.4 -Release: 6 +Release: 7 License: GPLv2 URL: https://www.clamav.net/ Source0: https://www.clamav.net/downloads/production/clamav-%version.tar.gz @@ -25,6 +25,7 @@ Patch0002: clamav-0.100.1-defaults_locations.patch Patch0003: clamav-0.99-private.patch Patch0004: clamav-0.100.0-umask.patch Patch0005: llvm-glibc.patch +Patch0006: clamav-Fix-int64-overflow-check.patch BuildRequires: autoconf automake gettext-devel libtool libtool-ltdl-devel BuildRequires: gcc-c++ zlib-devel bzip2-devel gmp-devel curl-devel json-c-devel @@ -404,6 +405,9 @@ test -e %_var/log/clamav-milter.log || { %changelog +* Fri Oct 09 2020 lingsheng - 0.101.4-7 +- Fix int64 overflow check + * Tue Sep 21 2020 chengzihan - 0.101.4-6 - Drop clamd@scann.service file, change /var/run to /run