mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
Fixes from review
This commit is contained in:
@@ -2617,7 +2617,7 @@ static int TLSX_TCA_Parse(WOLFSSL* ssl, const byte* input, word16 length,
|
||||
return BUFFER_ERROR;
|
||||
ato16(input + offset, &idSz);
|
||||
offset += OPAQUE16_LEN;
|
||||
if (idSz > length - offset)
|
||||
if ((offset > length) || (idSz > length - offset))
|
||||
return BUFFER_ERROR;
|
||||
id = input + offset;
|
||||
offset += idSz;
|
||||
|
17
tests/api.c
17
tests/api.c
@@ -21737,7 +21737,7 @@ static void test_wolfSSL_ASN1_TIME_adj(void)
|
||||
WOLFSSL_ASN1_TIME *asn_time, *s;
|
||||
int offset_day;
|
||||
long offset_sec;
|
||||
char date_str[CTC_DATE_SIZE];
|
||||
char date_str[CTC_DATE_SIZE + 1];
|
||||
time_t t;
|
||||
|
||||
printf(testingFmt, "wolfSSL_ASN1_TIME_adj()");
|
||||
@@ -21752,14 +21752,16 @@ static void test_wolfSSL_ASN1_TIME_adj(void)
|
||||
/* offset_sec = -45 * min;*/
|
||||
asn_time = wolfSSL_ASN1_TIME_adj(s, t, offset_day, offset_sec);
|
||||
AssertTrue(asn_time->type == asn_utc_time);
|
||||
XSTRNCPY(date_str, (const char*)&asn_time->data, sizeof(date_str)-1);
|
||||
XSTRNCPY(date_str, (const char*)&asn_time->data, CTC_DATE_SIZE);
|
||||
date_str[CTC_DATE_SIZE] = '\0';
|
||||
AssertIntEQ(0, XMEMCMP(date_str, "000222211500Z", 13));
|
||||
|
||||
/* negative offset */
|
||||
offset_sec = -45 * mini;
|
||||
asn_time = wolfSSL_ASN1_TIME_adj(s, t, offset_day, offset_sec);
|
||||
AssertTrue(asn_time->type == asn_utc_time);
|
||||
XSTRNCPY(date_str, (const char*)&asn_time->data, sizeof(date_str)-1);
|
||||
XSTRNCPY(date_str, (const char*)&asn_time->data, CTC_DATE_SIZE);
|
||||
date_str[CTC_DATE_SIZE] = '\0';
|
||||
AssertIntEQ(0, XMEMCMP(date_str, "000222194500Z", 13));
|
||||
|
||||
XFREE(s, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||
@@ -21776,7 +21778,8 @@ static void test_wolfSSL_ASN1_TIME_adj(void)
|
||||
offset_sec = 10 * mini;
|
||||
asn_time = wolfSSL_ASN1_TIME_adj(s, t, offset_day, offset_sec);
|
||||
AssertTrue(asn_time->type == asn_gen_time);
|
||||
XSTRNCPY(date_str, (const char*)&asn_time->data, sizeof(date_str)-1);
|
||||
XSTRNCPY(date_str, (const char*)&asn_time->data, CTC_DATE_SIZE);
|
||||
date_str[CTC_DATE_SIZE] = '\0';
|
||||
AssertIntEQ(0, XMEMCMP(date_str, "20550313091000Z", 15));
|
||||
|
||||
XFREE(s, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||
@@ -21791,13 +21794,15 @@ static void test_wolfSSL_ASN1_TIME_adj(void)
|
||||
offset_sec = 45 * mini;
|
||||
asn_time = wolfSSL_ASN1_TIME_adj(s, t, offset_day, offset_sec);
|
||||
AssertTrue(asn_time->type == asn_utc_time);
|
||||
XSTRNCPY(date_str, (const char*)&asn_time->data, sizeof(date_str)-1);
|
||||
XSTRNCPY(date_str, (const char*)&asn_time->data, CTC_DATE_SIZE);
|
||||
date_str[CTC_DATE_SIZE] = '\0';
|
||||
AssertIntEQ(0, XMEMCMP(date_str, "000222211515Z", 13));
|
||||
XFREE(asn_time, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||
|
||||
asn_time = wolfSSL_ASN1_TIME_adj(NULL, t, offset_day, offset_sec);
|
||||
AssertTrue(asn_time->type == asn_utc_time);
|
||||
XSTRNCPY(date_str, (const char*)&asn_time->data, sizeof(date_str)-1);
|
||||
XSTRNCPY(date_str, (const char*)&asn_time->data, CTC_DATE_SIZE);
|
||||
date_str[CTC_DATE_SIZE] = '\0';
|
||||
AssertIntEQ(0, XMEMCMP(date_str, "000222211515Z", 13));
|
||||
XFREE(asn_time, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||
|
||||
|
@@ -768,10 +768,11 @@ int wc_i2d_PKCS12(WC_PKCS12* pkcs12, byte** der, int* derSz)
|
||||
byte ar[MAX_LENGTH_SZ + 2];
|
||||
tmpSz = SetShortInt(ar, &tmpIdx, mac->itt, MAX_LENGTH_SZ + 2);
|
||||
if (tmpSz < 0) {
|
||||
WOLFSSL_MSG("Error returned by SetShortInt");
|
||||
return tmpSz;
|
||||
ret = tmpSz;
|
||||
}
|
||||
else {
|
||||
XMEMCPY(&sdBuf[idx], ar, tmpSz);
|
||||
}
|
||||
XMEMCPY(&sdBuf[idx], ar, tmpSz);
|
||||
}
|
||||
|
||||
totalSz += sdBufSz;
|
||||
|
@@ -3504,6 +3504,9 @@ static int wc_PKCS7_VerifyContentMessageDigest(PKCS7* pkcs7,
|
||||
digestSz = wc_HashGetDigestSize(hashType);
|
||||
if (digestSz < 0) {
|
||||
WOLFSSL_MSG("Invalid hash type");
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(digest, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
#endif
|
||||
return digestSz;
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user