Fixes for fsanitize reports.

This commit is contained in:
David Garske
2018-05-15 17:23:35 -07:00
parent 7a4da340d4
commit f021375c4b
4 changed files with 18 additions and 12 deletions

View File

@@ -373,12 +373,14 @@ int CheckCertCRL(WOLFSSL_CRL* crl, DecodedCert* cert)
WOLFSSL_MSG("Issuing missing CRL callback"); WOLFSSL_MSG("Issuing missing CRL callback");
url[0] = '\0'; url[0] = '\0';
if (cert->extCrlInfoSz < (int)sizeof(url) -1 ) { if (cert->extCrlInfo) {
XMEMCPY(url, cert->extCrlInfo, cert->extCrlInfoSz); if (cert->extCrlInfoSz < (int)sizeof(url) -1 ) {
url[cert->extCrlInfoSz] = '\0'; XMEMCPY(url, cert->extCrlInfo, cert->extCrlInfoSz);
} url[cert->extCrlInfoSz] = '\0';
else { }
WOLFSSL_MSG("CRL url too long"); else {
WOLFSSL_MSG("CRL url too long");
}
} }
crl->cm->cbMissingCRL(url); crl->cm->cbMissingCRL(url);

View File

@@ -7699,7 +7699,7 @@ int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert)
XMEMCPY(x509->serial, dCert->serial, EXTERNAL_SERIAL_SIZE); XMEMCPY(x509->serial, dCert->serial, EXTERNAL_SERIAL_SIZE);
x509->serialSz = dCert->serialSz; x509->serialSz = dCert->serialSz;
if (dCert->subjectCNLen < ASN_NAME_MAX) { if (dCert->subjectCN && dCert->subjectCNLen < ASN_NAME_MAX) {
XMEMCPY(x509->subjectCN, dCert->subjectCN, dCert->subjectCNLen); XMEMCPY(x509->subjectCN, dCert->subjectCN, dCert->subjectCNLen);
x509->subjectCN[dCert->subjectCNLen] = '\0'; x509->subjectCN[dCert->subjectCNLen] = '\0';
} }
@@ -8982,8 +8982,10 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
} }
/* store for callback use */ /* store for callback use */
if (args->dCert->subjectCNLen < ASN_NAME_MAX) { if (args->dCert->subjectCN &&
XMEMCPY(args->domain, args->dCert->subjectCN, args->dCert->subjectCNLen); args->dCert->subjectCNLen < ASN_NAME_MAX) {
XMEMCPY(args->domain, args->dCert->subjectCN,
args->dCert->subjectCNLen);
args->domain[args->dCert->subjectCNLen] = '\0'; args->domain[args->dCert->subjectCNLen] = '\0';
} }
else { else {

View File

@@ -3612,8 +3612,10 @@ int wolfSSL_SetVersion(WOLFSSL* ssl, int version)
/* Make a work from the front of random hash */ /* Make a work from the front of random hash */
static INLINE word32 MakeWordFromHash(const byte* hashID) static INLINE word32 MakeWordFromHash(const byte* hashID)
{ {
return (hashID[0] << 24) | (hashID[1] << 16) | (hashID[2] << 8) | return (((word32)hashID[0] << 24) |
hashID[3]; ((word32)hashID[1] << 16) |
((word32)hashID[2] << 8) |
((word32)hashID[3]));
} }
#endif /* !NO_CERTS || !NO_SESSION_CACHE */ #endif /* !NO_CERTS || !NO_SESSION_CACHE */

View File

@@ -485,7 +485,7 @@ void fp_mul_comba(fp_int *A, fp_int *B, fp_int *C)
for (ix = 0; ix < pa; ix++) { for (ix = 0; ix < pa; ix++) {
/* get offsets into the two bignums */ /* get offsets into the two bignums */
ty = MIN(ix, B->used-1); ty = MIN(ix, (B->used > 0 ? B->used - 1 : 0));
tx = ix - ty; tx = ix - ty;
/* setup temp aliases */ /* setup temp aliases */