Commit 0097a6f99 for clamav.net
commit 0097a6f99d9f6b78381e12b677a38fb62242c41a
Author: sebastianas <sebastianas@users.noreply.github.com>
Date: Sat Aug 1 00:13:13 2026 +0200
libclamav/crypto: Remove cl_ASN1_GetTimeT() (#1731)
The last user has been removed in commit fa15aa98c7d5e ("bb11594 - allow
for compilation against openssl 1.1.0"). This function is only exported
under CLAMAV_PRIVATE to be used within clamav, not by external users.
Removing the function will not cause an ABI break since it was not part
of the officially exported ABI. As a side effect it will compile against
OpenSSL 4.0 where the ASN1_TIME type has been made opaque.
Remove cl_ASN1_GetTimeT().
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
diff --git a/libclamav/clamav.h b/libclamav/clamav.h
index 8a3767f78..fa75677ad 100644
--- a/libclamav/clamav.h
+++ b/libclamav/clamav.h
@@ -2413,14 +2413,6 @@ extern int cl_validate_certificate_chain(char **authorities, char *crlpath, char
*/
extern X509 *cl_load_cert(const char *certpath);
-/**
- * @brief Parse an ASN1_TIME object.
- *
- * @param timeobj The ASN1_TIME object.
- * @return A pointer to a (struct tm). Adjusted for time zone and daylight savings time.
- */
-extern struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj);
-
/**
* @brief Load a CRL file into an X509_CRL object.
*
diff --git a/libclamav/crypto.c b/libclamav/crypto.c
index 8b398e402..968264811 100644
--- a/libclamav/crypto.c
+++ b/libclamav/crypto.c
@@ -1746,71 +1746,6 @@ X509 *cl_load_cert(const char *certpath)
return cert;
}
-struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj)
-{
- struct tm *t;
- char *str;
- const char *fmt = NULL;
- time_t localt;
-#ifdef _WIN32
- struct tm localtm, *ltm;
-#else
- struct tm localtm;
-#endif
-
- if (!(timeobj) || !(timeobj->data))
- return NULL;
-
- str = (char *)(timeobj->data);
- if (strlen(str) < 12)
- return NULL;
-
- t = (struct tm *)calloc(1, sizeof(struct tm));
- if (!(t))
- return NULL;
-
- if (timeobj->type == V_ASN1_UTCTIME) {
- /* two digit year */
- fmt = "%y%m%d%H%M%S";
- if (str[3] == '0') {
- str[2] = '0';
- str[3] = '9';
- } else {
- str[3]--;
- }
- } else if (timeobj->type == V_ASN1_GENERALIZEDTIME) {
- /* four digit year */
- fmt = "%Y%m%d%H%M%S";
- if (str[5] == '0') {
- str[4] = '0';
- str[5] = '9';
- } else {
- str[5]--;
- }
- }
-
- if (!(fmt)) {
- free(t);
- return NULL;
- }
-
- if (!strptime(str, fmt, t)) {
- free(t);
- return NULL;
- }
-
- /* Convert to local time */
- localt = time(NULL);
-#ifdef _WIN32
- ltm = localtime(&localt);
- memcpy((void *)(&localtm), (void *)ltm, sizeof(struct tm));
-#else
- localtime_r(&localt, &localtm);
-#endif
- t->tm_isdst = localtm.tm_isdst;
- return t;
-}
-
X509_CRL *cl_load_crl(const char *file)
{
X509_CRL *x = NULL;
diff --git a/libclamav/libclamav.map b/libclamav/libclamav.map
index 809341f42..f3efe1a33 100644
--- a/libclamav/libclamav.map
+++ b/libclamav/libclamav.map
@@ -271,7 +271,6 @@ CLAMAV_PRIVATE {
cl_verify_signature_hash_x509;
cl_verify_signature_hash_x509_keyfile;
cl_load_cert;
- cl_ASN1_GetTimeT;
cl_load_crl;
cl_sign_data_keyfile;
cl_sign_data;