Skip to content

Commit 1739c12

Browse files
sebastianasval-ms
authored andcommitted
libclamav/crypto: Remove cl_ASN1_GetTimeT()
The last user has been removed in commit fa15aa9 ("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>
1 parent 9d0878e commit 1739c12

3 files changed

Lines changed: 0 additions & 74 deletions

File tree

libclamav/clamav.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,14 +2413,6 @@ extern int cl_validate_certificate_chain(char **authorities, char *crlpath, char
24132413
*/
24142414
extern X509 *cl_load_cert(const char *certpath);
24152415

2416-
/**
2417-
* @brief Parse an ASN1_TIME object.
2418-
*
2419-
* @param timeobj The ASN1_TIME object.
2420-
* @return A pointer to a (struct tm). Adjusted for time zone and daylight savings time.
2421-
*/
2422-
extern struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj);
2423-
24242416
/**
24252417
* @brief Load a CRL file into an X509_CRL object.
24262418
*

libclamav/crypto.c

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,71 +1746,6 @@ X509 *cl_load_cert(const char *certpath)
17461746
return cert;
17471747
}
17481748

1749-
struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj)
1750-
{
1751-
struct tm *t;
1752-
char *str;
1753-
const char *fmt = NULL;
1754-
time_t localt;
1755-
#ifdef _WIN32
1756-
struct tm localtm, *ltm;
1757-
#else
1758-
struct tm localtm;
1759-
#endif
1760-
1761-
if (!(timeobj) || !(timeobj->data))
1762-
return NULL;
1763-
1764-
str = (char *)(timeobj->data);
1765-
if (strlen(str) < 12)
1766-
return NULL;
1767-
1768-
t = (struct tm *)calloc(1, sizeof(struct tm));
1769-
if (!(t))
1770-
return NULL;
1771-
1772-
if (timeobj->type == V_ASN1_UTCTIME) {
1773-
/* two digit year */
1774-
fmt = "%y%m%d%H%M%S";
1775-
if (str[3] == '0') {
1776-
str[2] = '0';
1777-
str[3] = '9';
1778-
} else {
1779-
str[3]--;
1780-
}
1781-
} else if (timeobj->type == V_ASN1_GENERALIZEDTIME) {
1782-
/* four digit year */
1783-
fmt = "%Y%m%d%H%M%S";
1784-
if (str[5] == '0') {
1785-
str[4] = '0';
1786-
str[5] = '9';
1787-
} else {
1788-
str[5]--;
1789-
}
1790-
}
1791-
1792-
if (!(fmt)) {
1793-
free(t);
1794-
return NULL;
1795-
}
1796-
1797-
if (!strptime(str, fmt, t)) {
1798-
free(t);
1799-
return NULL;
1800-
}
1801-
1802-
/* Convert to local time */
1803-
localt = time(NULL);
1804-
#ifdef _WIN32
1805-
ltm = localtime(&localt);
1806-
memcpy((void *)(&localtm), (void *)ltm, sizeof(struct tm));
1807-
#else
1808-
localtime_r(&localt, &localtm);
1809-
#endif
1810-
t->tm_isdst = localtm.tm_isdst;
1811-
return t;
1812-
}
1813-
18141749
X509_CRL *cl_load_crl(const char *file)
18151750
{
18161751
X509_CRL *x = NULL;

libclamav/libclamav.map

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ CLAMAV_PRIVATE {
271271
cl_verify_signature_hash_x509;
272272
cl_verify_signature_hash_x509_keyfile;
273273
cl_load_cert;
274-
cl_ASN1_GetTimeT;
275274
cl_load_crl;
276275
cl_sign_data_keyfile;
277276
cl_sign_data;

0 commit comments

Comments
 (0)