package/clamav: fix broken database updates with OpenSSL 4.1
PATCH 1/1 package/clamav: fix broken database updates with OpenSSL 4.1
Removed patch 0001 and added a patch series cherry-picked from
https://github.com/markarce/clamav/commits/perf/cache-evp-md-fetch-1.5/
exluding all unit test updates.
The series also includes a different fix for the ASN1_TIME type change previously solved by patch 0001.
---
Gitlab pipelines passed:
https://gitlab.com/bkuhls/buildroot/-/commits/2e320b39e415e4e8dcec431b8de24d2da4572445
...SN1_TIME-through-accessors-in-cl_ASN.patch | 110 ++++ ...-crypto-Remove-cl_ASN1_GetTimeT-1731.patch | 136 ----- ...EVP_MD-handles-to-fix-per-hash-provi.patch | 501 ++++++++++++++++++ ...en-EVP-digest-cache-failure-handling.patch | 273 ++++++++++ 4 files changed, 884 insertions(+), 136 deletions(-) create mode 100644 package/clamav/0001-libclamav-Read-ASN1_TIME-through-accessors-in-cl_ASN.patch delete mode 100644 package/clamav/0001-libclamav-crypto-Remove-cl_ASN1_GetTimeT-1731.patch create mode 100644 package/clamav/0002-libclamav-cache-EVP_MD-handles-to-fix-per-hash-provi.patch create mode 100644 package/clamav/0003-libclamav-harden-EVP-digest-cache-failure-handling.patch
package/clamav/0001-libclamav-Read-ASN1_TIME-through-accessors-in-cl_ASN.patch new file +110 -0
@@ -0,0 +1,110 @@ +From 923cc3d3b4e22a5fb8adeb8cc8404040ddcc1987 Mon Sep 17 00:00:00 2001 +From: Mark Arce <[email protected]> +Date: Wed, 28 Oct 2026 16:17:29 -0700 +Subject: [PATCH] libclamav: Read ASN1_TIME through accessors in + cl_ASN1_GetTimeT() + +ASN1_TIME is opaque in OpenSSL 4, so reading timeobj->data and +timeobj->type no longer compiles. Use ASN1_STRING_get0_data(), +ASN1_STRING_length() and ASN1_STRING_type() instead. + +Parse a length-bounded, NUL-terminated copy of the time string. OpenSSL does +not guarantee the data is NUL-terminated (ASN1_STRING_length(3)), and +OpenSSL 4 does not terminate it, so the previous strlen() read past the end. +The function also decremented the month digits in the caller's object, so a +second call on the same object shifted the month again. The returned values +are unchanged. + +Keep cl_ASN1_GetTimeT() through 1.5 so code built against clamav.h keeps +working, and mark it deprecated. main removes it for 1.6 (#1731). + +Co-Authored-By: Claude Opus 5.5 <[email protected]> + +Upstream: https://github.com/Cisco-Talos/clamav/pull/1873#issuecomment-6485066645 + +Signed-off-by: Bernd Kuhls <[email protected]> +--- + libclamav/clamav.h | 2 ++ + libclamav/crypto.c | 23 ++++++++++++++++++----- + 2 files changed, 20 insertions(+), 5 deletions(-) + +diff --git a/libclamav/clamav.h b/libclamav/clamav.h +index b41d39e39..a12391983 100644 +--- a/libclamav/clamav.h ++++ b/libclamav/clamav.h +@@ -2605,6 +2605,8 @@ extern X509 *cl_load_cert(const char *certpath); + * + * @param timeobj The ASN1_TIME object. + * @return A pointer to a (struct tm). Adjusted for time zone and daylight savings time. ++ * ++ * @deprecated This function is deprecated and will be removed in ClamAV 1.6. + */ + extern struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj); + +diff --git a/libclamav/crypto.c b/libclamav/crypto.c +index dfbdeb9cb..13f7fea03 100644 +--- a/libclamav/crypto.c ++++ b/libclamav/crypto.c +@@ -55,6 +55,7 @@ + + #if OPENSSL_VERSION_NUMBER < 0x10100000L + #define X509_CRL_get0_nextUpdate X509_CRL_get_nextUpdate ++#define ASN1_STRING_get0_data ASN1_STRING_data + #endif + + #if !defined(_WIN32) +@@ -1757,7 +1758,9 @@ X509 *cl_load_cert(const char *certpath) + struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj) + { + struct tm *t; +- char *str; ++ const unsigned char *data; ++ int len; ++ char str[32]; + const char *fmt = NULL; + time_t localt; + #ifdef _WIN32 +@@ -1766,10 +1769,20 @@ struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj) + struct tm localtm; + #endif + +- if (!(timeobj) || !(timeobj->data)) ++ if (!(timeobj)) + return NULL; + +- str = (char *)(timeobj->data); ++ data = ASN1_STRING_get0_data(timeobj); ++ len = ASN1_STRING_length(timeobj); ++ if (!(data) || len <= 0) ++ return NULL; ++ ++ /* Parse a NUL-terminated copy: OpenSSL doesn't guarantee the data is terminated, and the month ++ * adjustment below must not modify the caller's ASN1_TIME. */ ++ if ((size_t)len >= sizeof(str)) ++ len = sizeof(str) - 1; ++ memcpy(str, data, len); ++ str[len] = '\0'; + if (strlen(str) < 12) + return NULL; + +@@ -1777,7 +1790,7 @@ struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj) + if (!(t)) + return NULL; + +- if (timeobj->type == V_ASN1_UTCTIME) { ++ if (ASN1_STRING_type(timeobj) == V_ASN1_UTCTIME) { + /* two digit year */ + fmt = "%y%m%d%H%M%S"; + if (str[3] == '0') { +@@ -1786,7 +1799,7 @@ struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj) + } else { + str[3]--; + } +- } else if (timeobj->type == V_ASN1_GENERALIZEDTIME) { ++ } else if (ASN1_STRING_type(timeobj) == V_ASN1_GENERALIZEDTIME) { + /* four digit year */ + fmt = "%Y%m%d%H%M%S"; + if (str[5] == '0') { +-- +2.47.3 +
package/clamav/0001-libclamav-crypto-Remove-cl_ASN1_GetTimeT-1731.patch deleted +0 -136
136 lines not on this page · raw message
package/clamav/0002-libclamav-cache-EVP_MD-handles-to-fix-per-hash-provi.patch new file +501 -0
501 lines not on this page · raw message
package/clamav/0003-libclamav-harden-EVP-digest-cache-failure-handling.patch new file +273 -0
273 lines not on this page · raw message
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 7 lines · Bernd Kuhls
Removed patch 0001 and added a patch series cherry-picked from
https://github.com/markarce/clamav/commits/perf/cache-evp-md-fetch-1.5/
exluding all unit test updates.
The series also includes a different fix for theASN1_TIMEtype change previously solved by patch 0001.Signed-off-by Bernd Kuhls <[email protected]>
As usual for fixes: which commit is being fixed by this? Is it 8df2ad69de03c61378a85dc08daa1e9a2fa46920 ?
If yes, then please add:
Thanks a lot!
Thomas Petazzoni
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
A message that is not in the archive (sent off-list or not yet received): auuqeiJezoi26OeE__37191.4018340007$1793829569$gmane$org@windsurf
Am Wed, 4 Nov 2026 22:59:03 +0100 schrieb Thomas Petazzoni via buildroot:
Quoted 7 lines · Bernd Kuhls
Quoted 6 lines
Removed patch 0001 and added a patch series cherry-picked from
https://github.com/markarce/clamav/commits/perf/cache-evp-md-fetch-1.5/
exluding all unit test updates.
The series also includes a different fix for theASN1_TIMEtype change previously solved by patch 0001.
Quoted 5 lines
Quoted 2 lines
Signed-off-by: Bernd Kuhls
<[email protected]>As usual for fixes: which commit is being fixed by this? Is it
8df2ad69de03c61378a85dc08daa1e9a2fa46920?
Hi Thomas,
no, the error fixed by this patch only occurs with OpenSSL >= 4.1, not with the OpenSSL versions we currently have in buildroot. So there is no need to backport this patch to any LTS branches.
Regards, Bernd
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot