forked from wolfSSL/wolfssl
Fix wolfssl_asn1_time_to_tm setting unexpected fields in tm struct.
This commit is contained in:
@@ -3652,6 +3652,9 @@ static int wolfssl_asn1_time_to_tm(const WOLFSSL_ASN1_TIME* asnTime,
|
|||||||
const unsigned char* asn1TimeBuf;
|
const unsigned char* asn1TimeBuf;
|
||||||
int asn1TimeBufLen;
|
int asn1TimeBufLen;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
#ifdef XMKTIME
|
||||||
|
struct tm localTm = {0};
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get the string buffer - fixed array, can't fail. */
|
/* Get the string buffer - fixed array, can't fail. */
|
||||||
asn1TimeBuf = wolfSSL_ASN1_TIME_get_data(asnTime);
|
asn1TimeBuf = wolfSSL_ASN1_TIME_get_data(asnTime);
|
||||||
@@ -3706,8 +3709,13 @@ static int wolfssl_asn1_time_to_tm(const WOLFSSL_ASN1_TIME* asnTime,
|
|||||||
tm->tm_sec += (asn1TimeBuf[i] - '0');
|
tm->tm_sec += (asn1TimeBuf[i] - '0');
|
||||||
|
|
||||||
#ifdef XMKTIME
|
#ifdef XMKTIME
|
||||||
/* Call XMKTIME on tm to get tm_wday and tm_yday fields populated. */
|
XMEMCPY(&localTm, tm, sizeof(struct tm));
|
||||||
XMKTIME(tm);
|
/* Call XMKTIME on tm to get tm_wday and tm_yday fields populated.
|
||||||
|
Note that localTm is used here to avoid modifying other fields,
|
||||||
|
such as tm_isdst/tm_gmtoff. */
|
||||||
|
XMKTIME(&localTm);
|
||||||
|
tm->tm_wday = localTm.tm_wday;
|
||||||
|
tm->tm_yday = localTm.tm_yday;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user