wolfcrypt/src/asn.c: in C89 codepath of GetFormattedTime(), add buffer size checks before calls to sprintf().

This commit is contained in:
Daniel Pouzzner
2022-05-27 14:17:21 -05:00
parent aca199cb05
commit 8c10c3776d

View File

@@ -12389,6 +12389,10 @@ int GetFormattedTime(void* currTime, byte* buf, word32 len)
mini = ts->tm_min;
sec = ts->tm_sec;
#if defined(WOLF_C89)
if (len < 14) {
WOLFSSL_MSG("buffer for GetFormattedTime is too short.");
return BUFFER_E;
}
ret = XSPRINTF((char*)buf,
#else
ret = XSNPRINTF((char*)buf, len,
@@ -12405,6 +12409,10 @@ int GetFormattedTime(void* currTime, byte* buf, word32 len)
mini = ts->tm_min;
sec = ts->tm_sec;
#if defined(WOLF_C89)
if (len < 16) {
WOLFSSL_MSG("buffer for GetFormattedTime is too short.");
return BUFFER_E;
}
ret = XSPRINTF((char*)buf,
#else
ret = XSNPRINTF((char*)buf, len,