Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions libclamav/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1748,28 +1748,31 @@

struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj)
{
struct tm *t;
char *str;
const char *fmt = NULL;
struct tm *ret = NULL;
struct tm *t = NULL;
char *str = NULL;
const char *data, *fmt = NULL;
time_t localt;
#ifdef _WIN32
struct tm localtm, *ltm;
#else
struct tm localtm;
#endif

if (!(timeobj) || !(timeobj->data))
return NULL;
if (timeobj == NULL || (data = ASN1_STRING_get0_data(timeobj)) == NULL)
goto err;

if ((str = strndup(data, ASN1_STRING_length(timeobj))) == NULL)

Check warning on line 1765 in libclamav/crypto.c

View workflow job for this annotation

GitHub Actions / build-windows

'=': 'char *' differs in levels of indirection from 'int'
Comment thread
bob-beck marked this conversation as resolved.
Outdated
goto err;

str = (char *)(timeobj->data);
if (strlen(str) < 12)
return NULL;
goto err;

t = (struct tm *)calloc(1, sizeof(struct tm));
if (!(t))
return NULL;
goto err;

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') {
Expand All @@ -1778,7 +1781,7 @@
} 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') {
Expand All @@ -1789,15 +1792,11 @@
}
}

if (!(fmt)) {
free(t);
return NULL;
}
if (!(fmt))
goto err;

if (!strptime(str, fmt, t)) {
free(t);
return NULL;
}
if (!strptime(str, fmt, t))
goto err;

/* Convert to local time */
localt = time(NULL);
Expand All @@ -1808,7 +1807,15 @@
localtime_r(&localt, &localtm);
#endif
t->tm_isdst = localtm.tm_isdst;
return t;

ret = t;
t = NULL;

err:
free(t);
free(str);

return ret;
}

X509_CRL *cl_load_crl(const char *file)
Expand Down
Loading