Merge pull request #5096 from JacobBarthelmeh/Testing

- static analysis test fixes
This commit is contained in:
David Garske
2022-05-02 10:05:08 -07:00
committed by GitHub
2 changed files with 36 additions and 32 deletions

View File

@@ -12737,7 +12737,7 @@ WOLFSSL_ABI
int wolfSSL_CTX_set_timeout(WOLFSSL_CTX* ctx, unsigned int to) int wolfSSL_CTX_set_timeout(WOLFSSL_CTX* ctx, unsigned int to)
{ {
#if defined(WOLFSSL_ERROR_CODE_OPENSSL) #if defined(WOLFSSL_ERROR_CODE_OPENSSL)
word32 prev_timeout; word32 prev_timeout = 0;
#endif #endif
int ret = WOLFSSL_SUCCESS; int ret = WOLFSSL_SUCCESS;

View File

@@ -950,9 +950,11 @@ static void test_wolfSSL_CTX_trust_peer_cert(void)
AssertIntEQ(wolfSSL_trust_peer_cert(ssl, cliCertFile, AssertIntEQ(wolfSSL_trust_peer_cert(ssl, cliCertFile,
WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS); WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS);
#ifdef WOLFSSL_LOCAL_X509_STORE
/* unload cert */ /* unload cert */
AssertIntNE(wolfSSL_Unload_trust_peers(NULL), WOLFSSL_SUCCESS); AssertIntNE(wolfSSL_Unload_trust_peers(NULL), WOLFSSL_SUCCESS);
AssertIntEQ(wolfSSL_Unload_trust_peers(ssl), WOLFSSL_SUCCESS); AssertIntEQ(wolfSSL_Unload_trust_peers(ssl), WOLFSSL_SUCCESS);
#endif
#endif #endif
/* Test of loading certs from buffers */ /* Test of loading certs from buffers */
@@ -34252,43 +34254,45 @@ static void test_wolfSSL_Tls13_Key_Logging_test(void)
#endif #endif
/* check if the keylog file exists */ /* check if the keylog file exists */
{
char buff[300] = {0}; char buff[300] = {0};
int found[4] = {0}; int found[4] = {0};
int numfnd = 0;
int i;
fp = XFOPEN("./MyKeyLog.txt", "r"); fp = XFOPEN("./MyKeyLog.txt", "r");
AssertNotNull(fp); AssertNotNull(fp);
while(XFGETS( buff, (int)sizeof(buff),fp) != NULL ) { while (XFGETS( buff, (int)sizeof(buff),fp) != NULL ) {
if(0 == strncmp(buff,"CLIENT_HANDSHAKE_TRAFFIC_SECRET ", if (0 == strncmp(buff,"CLIENT_HANDSHAKE_TRAFFIC_SECRET ",
sizeof("CLIENT_HANDSHAKE_TRAFFIC_SECRET ")-1)) { sizeof("CLIENT_HANDSHAKE_TRAFFIC_SECRET ")-1)) {
found[0] = 1; found[0] = 1;
continue; continue;
} }
else if(0 == strncmp(buff,"SERVER_HANDSHAKE_TRAFFIC_SECRET ", else if (0 == strncmp(buff,"SERVER_HANDSHAKE_TRAFFIC_SECRET ",
sizeof("SERVER_HANDSHAKE_TRAFFIC_SECRET ")-1)) { sizeof("SERVER_HANDSHAKE_TRAFFIC_SECRET ")-1)) {
found[1] = 1; found[1] = 1;
continue; continue;
} }
else if(0 == strncmp(buff,"CLIENT_TRAFFIC_SECRET_0 ", else if (0 == strncmp(buff,"CLIENT_TRAFFIC_SECRET_0 ",
sizeof("CLIENT_TRAFFIC_SECRET_0 ")-1)) { sizeof("CLIENT_TRAFFIC_SECRET_0 ")-1)) {
found[2] = 1; found[2] = 1;
continue; continue;
} }
else if(0 == strncmp(buff,"SERVER_TRAFFIC_SECRET_0 ", else if (0 == strncmp(buff,"SERVER_TRAFFIC_SECRET_0 ",
sizeof("SERVER_TRAFFIC_SECRET_0 ")-1)) { sizeof("SERVER_TRAFFIC_SECRET_0 ")-1)) {
found[3] = 1; found[3] = 1;
continue; continue;
} }
} }
XFCLOSE(fp); XFCLOSE(fp);
int numfnd = 0; for (i = 0; i < 4; i++) {
for( uint i = 0; i < 4; i++) {
if( found[i] != 0) if( found[i] != 0)
numfnd++; numfnd++;
} }
AssertIntEQ( numfnd,4 ); AssertIntEQ(numfnd, 4);
}
printf(resultFmt, passed); printf(resultFmt, passed);