cppcheck: fixes

pull/3569/head
Sean Parkinson 2020-12-16 16:44:22 +10:00
parent 922ca916a9
commit 75c062a298
19 changed files with 137 additions and 128 deletions

View File

@ -59,12 +59,12 @@ unsigned int LowResTimer(void)
/* This is used by wolfCrypt benchmark tool only */
double current_time(int reset)
{
double time;
int timeMs = gTimeMs;
double timeNow;
int timeMs = gTimeMs;
(void)reset;
time = (timeMs / 1000); // sec
time += (double)(timeMs % 1000) / 1000; // ms
return time;
timeNow = (timeMs / 1000); // sec
timeNow += (double)(timeMs % 1000) / 1000; // ms
return timeNow;
}
#endif

View File

@ -687,8 +687,8 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
err_sys("Client buffer malloc failed");
}
doExit:
if(tx_buffer) XFREE(tx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if(rx_buffer) XFREE(rx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (tx_buffer) XFREE(tx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (rx_buffer) XFREE(rx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
else {
err_sys("wolfSSL_connect failed");
@ -701,10 +701,11 @@ doExit:
if (exitWithRet)
return err;
printf(
#if !defined(__MINGW32__)
printf("wolfSSL Client Benchmark %zu bytes\n"
"wolfSSL Client Benchmark %zu bytes\n"
#else
printf("wolfSSL Client Benchmark %d bytes\n"
"wolfSSL Client Benchmark %d bytes\n"
#endif
"\tConnect %8.3f ms\n"
"\tTX %8.3f ms (%8.3f MBps)\n"

View File

@ -6591,25 +6591,26 @@ void FreeHandshakeResources(WOLFSSL* ssl)
int dtype;
#ifdef HAVE_ECC
dtype = DYNAMIC_TYPE_ECC;
#elif defined(HAVE_CURVE25519)
dtype = DYNAMIC_TYPE_CURVE25519;
#else
dtype = DYNAMIC_TYPE_CURVE448;
#endif
#ifdef HAVE_CURVE25519
#ifdef HAVE_ECC
#if defined(HAVE_ECC) && defined(HAVE_CURVE25519)
if (ssl->peerX25519KeyPresent ||
ssl->eccTempKeyPresent == DYNAMIC_TYPE_CURVE25519)
#endif /* HAVE_ECC */
{
dtype = DYNAMIC_TYPE_CURVE25519;
}
#endif /* HAVE_CURVE25519 */
#ifdef HAVE_CURVE448
#ifdef HAVE_ECC
#endif
#if (defined(HAVE_ECC) || defined(HAVE_CURVE25519)) && \
defined(HAVE_CURVE448)
if (ssl->peerX448KeyPresent ||
ssl->eccTempKeyPresent == DYNAMIC_TYPE_CURVE448)
#endif /* HAVE_ECC */
{
dtype = DYNAMIC_TYPE_CURVE448;
}
#endif /* HAVE_CURVE448 */
#endif
FreeKey(ssl, dtype, (void**)&ssl->eccTempKey);
ssl->eccTempKeyPresent = 0;
}
@ -13066,7 +13067,7 @@ static WC_INLINE int DtlsCheckWindow(WOLFSSL* ssl)
#ifdef WOLFSSL_MULTICAST
static WC_INLINE word32 UpdateHighwaterMark(word32 cur, word32 first,
word32 second, word32 max)
word32 second, word32 high)
{
word32 newCur = 0;
@ -13074,8 +13075,8 @@ static WC_INLINE word32 UpdateHighwaterMark(word32 cur, word32 first,
newCur = first;
else if (cur < second)
newCur = second;
else if (cur < max)
newCur = max;
else if (cur < high)
newCur = high;
return newCur;
}

View File

@ -3778,7 +3778,9 @@ static int DoHandShake(const byte* input, int* sslBytes,
break;
}
#ifdef HAVE_EXTENDED_MASTER
exit:
#endif
#ifdef HAVE_MAX_FRAGMENT
if (session->tlsFragBuf) {
XFREE(session->tlsFragBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);

View File

@ -1170,7 +1170,7 @@ int wolfSSL_mcast_get_max_peers(void)
#ifdef WOLFSSL_DTLS
static WC_INLINE word32 UpdateHighwaterMark(word32 cur, word32 first,
word32 second, word32 max)
word32 second, word32 high)
{
word32 newCur = 0;
@ -1178,8 +1178,8 @@ static WC_INLINE word32 UpdateHighwaterMark(word32 cur, word32 first,
newCur = first;
else if (cur < second)
newCur = second;
else if (cur < max)
newCur = max;
else if (cur < high)
newCur = high;
return newCur;
}
@ -1505,7 +1505,7 @@ int wolfSSL_METHOD_GetObjectSize(void)
int wolfSSL_CTX_load_static_memory(WOLFSSL_CTX** ctx, wolfSSL_method_func method,
unsigned char* buf, unsigned int sz,
int flag, int max)
int flag, int maxSz)
{
WOLFSSL_HEAP* heap;
WOLFSSL_HEAP_HINT* hint;
@ -1564,15 +1564,15 @@ int wolfSSL_CTX_load_static_memory(WOLFSSL_CTX** ctx, wolfSSL_method_func method
/* determine what max applies too */
if (flag & WOLFMEM_IO_POOL || flag & WOLFMEM_IO_POOL_FIXED) {
heap->maxIO = max;
heap->maxIO = maxSz;
}
else { /* general memory used in handshakes */
heap->maxHa = max;
heap->maxHa = maxSz;
}
heap->flag |= flag;
(void)max;
(void)maxSz;
(void)method;
return WOLFSSL_SUCCESS;

View File

@ -565,7 +565,11 @@ int MakeTlsMasterSecret(WOLFSSL* ssl)
ssl->arrays->clientRandom,
ssl->arrays->serverRandom,
ssl->arrays->tsip_masterSecret);
#else
ret = NOT_COMPILED_IN;
#endif
} else
#endif
@ -9027,18 +9031,18 @@ static int TLSX_EarlyData_GetSize(byte msgType, word16* pSz)
* Assumes that the the output buffer is big enough to hold data.
* In messages: ClientHello, EncryptedExtensions and NewSessionTicket.
*
* max The maximum early data size.
* maxSz The maximum early data size.
* output The buffer to write into.
* msgType The type of the message this extension is being written into.
* returns the number of bytes written into the buffer.
*/
static int TLSX_EarlyData_Write(word32 max, byte* output, byte msgType,
static int TLSX_EarlyData_Write(word32 maxSz, byte* output, byte msgType,
word16* pSz)
{
if (msgType == client_hello || msgType == encrypted_extensions)
return 0;
else if (msgType == session_ticket) {
c32toa(max, output);
c32toa(maxSz, output);
*pSz += OPAQUE32_LEN;
return 0;
}
@ -9095,11 +9099,11 @@ static int TLSX_EarlyData_Parse(WOLFSSL* ssl, byte* input, word16 length,
/* Use the data to create a new Early Data object in the extensions.
*
* ssl The SSL/TLS object.
* max The maximum early data size.
* ssl The SSL/TLS object.
* maxSz The maximum early data size.
* returns 0 on success and other values indicate failure.
*/
int TLSX_EarlyData_Use(WOLFSSL* ssl, word32 max)
int TLSX_EarlyData_Use(WOLFSSL* ssl, word32 maxSz)
{
int ret = 0;
TLSX* extension;
@ -9118,7 +9122,7 @@ int TLSX_EarlyData_Use(WOLFSSL* ssl, word32 max)
}
extension->resp = 1;
extension->val = max;
extension->val = maxSz;
return 0;
}

View File

@ -5188,7 +5188,7 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
goto exit_scv;
}
if (args->length <= 0) {
if (args->length == 0) {
ERROR_OUT(NO_PRIVATE_KEY, exit_scv);
}

View File

@ -6143,12 +6143,12 @@ static int test_wc_InitBlake2b (void)
int ret = 0;
#ifdef HAVE_BLAKE2
Blake2b blake2;
Blake2b blake2b;
printf(testingFmt, "wc_InitBlake2B()");
/* Test good arg. */
ret = wc_InitBlake2b(&blake2, 64);
ret = wc_InitBlake2b(&blake2b, 64);
if (ret != 0) {
ret = WOLFSSL_FATAL_ERROR;
}
@ -6173,7 +6173,7 @@ static int test_wc_InitBlake2b (void)
}
if (!ret) {
ret = wc_InitBlake2b(&blake2, 128);
ret = wc_InitBlake2b(&blake2b, 128);
if (ret == 0) {
ret = WOLFSSL_FATAL_ERROR;
} else {
@ -6191,7 +6191,7 @@ static int test_wc_InitBlake2b (void)
}
if (!ret) {
ret = wc_InitBlake2b(&blake2, 0);
ret = wc_InitBlake2b(&blake2b, 0);
if (ret == 0) {
ret = WOLFSSL_FATAL_ERROR;
} else {
@ -6212,7 +6212,7 @@ static int test_wc_InitBlake2b_WithKey (void)
{
int ret = 0;
#ifdef HAVE_BLAKE2
Blake2b blake2;
Blake2b blake2b;
word32 digestSz = BLAKE2B_KEYBYTES;
byte key[BLAKE2B_KEYBYTES];
word32 keylen = BLAKE2B_KEYBYTES;
@ -6222,7 +6222,7 @@ static int test_wc_InitBlake2b_WithKey (void)
printf(testingFmt, "wc_InitBlake2b_WithKey()");
/* Test good arg. */
ret = wc_InitBlake2b_WithKey(&blake2, digestSz, key, keylen);
ret = wc_InitBlake2b_WithKey(&blake2b, digestSz, key, keylen);
if (ret != 0) {
ret = WOLFSSL_FATAL_ERROR;
}
@ -6234,13 +6234,13 @@ static int test_wc_InitBlake2b_WithKey (void)
}
}
if (ret == 0) {
ret = wc_InitBlake2b_WithKey(&blake2, digestSz, key, 256);
ret = wc_InitBlake2b_WithKey(&blake2b, digestSz, key, 256);
if (ret == BAD_FUNC_ARG) {
ret = 0;
}
}
if (ret == 0) {
ret = wc_InitBlake2b_WithKey(&blake2, digestSz, NULL, keylen);
ret = wc_InitBlake2b_WithKey(&blake2b, digestSz, NULL, keylen);
}
printf(resultFmt, ret == 0 ? passed : failed);
@ -6256,7 +6256,7 @@ static int test_wc_InitBlake2s_WithKey (void)
{
int ret = 0;
#ifdef HAVE_BLAKE2S
Blake2s blake2;
Blake2s blake2s;
word32 digestSz = BLAKE2S_KEYBYTES;
byte *key = (byte*)"01234567890123456789012345678901";
word32 keylen = BLAKE2S_KEYBYTES;
@ -6264,7 +6264,7 @@ static int test_wc_InitBlake2s_WithKey (void)
printf(testingFmt, "wc_InitBlake2s_WithKey()");
/* Test good arg. */
ret = wc_InitBlake2s_WithKey(&blake2, digestSz, key, keylen);
ret = wc_InitBlake2s_WithKey(&blake2s, digestSz, key, keylen);
if (ret != 0) {
ret = WOLFSSL_FATAL_ERROR;
}
@ -6276,13 +6276,13 @@ static int test_wc_InitBlake2s_WithKey (void)
}
}
if (ret == 0) {
ret = wc_InitBlake2s_WithKey(&blake2, digestSz, key, 256);
ret = wc_InitBlake2s_WithKey(&blake2s, digestSz, key, 256);
if (ret == BAD_FUNC_ARG) {
ret = 0;
}
}
if (ret == 0) {
ret = wc_InitBlake2s_WithKey(&blake2, digestSz, NULL, keylen);
ret = wc_InitBlake2s_WithKey(&blake2s, digestSz, NULL, keylen);
}
printf(resultFmt, ret == 0 ? passed : failed);
@ -17790,7 +17790,7 @@ static int test_wc_curve25519_export_key_raw (void)
}
prvkSz = CURVE25519_KEYSIZE;
/* prvkSz = CURVE25519_KEYSIZE; */
pubkSz = CURVE25519_KEYSIZE;
if(BAD_FUNC_ARG != wc_curve25519_export_key_raw(
@ -17846,7 +17846,7 @@ static int test_wc_curve25519_export_key_raw (void)
}
prvkSz = CURVE25519_KEYSIZE;
pubkSz = CURVE25519_KEYSIZE;
/* pubkSz = CURVE25519_KEYSIZE; */
if(0 != wc_curve25519_export_key_raw(&key, privateKey, &prvkSz,
publicKey, &pubkSz)){
@ -17986,7 +17986,7 @@ static int test_wc_curve25519_export_key_raw_ex (void)
return 1;
}
prvkSz = CURVE25519_KEYSIZE;
/* prvkSz = CURVE25519_KEYSIZE; */
pubkSz = CURVE25519_KEYSIZE;
if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey,
@ -18013,7 +18013,7 @@ static int test_wc_curve25519_export_key_raw_ex (void)
}
prvkSz = CURVE25519_KEYSIZE;
pubkSz = CURVE25519_KEYSIZE;
/* pubkSz = CURVE25519_KEYSIZE; */
if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( NULL, privateKey,
&prvkSz, publicKey, &pubkSz, EC25519_BIG_ENDIAN)){
@ -18051,7 +18051,7 @@ static int test_wc_curve25519_export_key_raw_ex (void)
return 1;
}
prvkSz = CURVE25519_KEYSIZE;
/* prvkSz = CURVE25519_KEYSIZE; */
pubkSz = CURVE25519_KEYSIZE;
if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey,
@ -18080,7 +18080,7 @@ static int test_wc_curve25519_export_key_raw_ex (void)
/* illegal value for endien */
prvkSz = CURVE25519_KEYSIZE;
pubkSz = CURVE25519_KEYSIZE;
/* pubkSz = CURVE25519_KEYSIZE; */
if(BAD_FUNC_ARG != wc_curve25519_export_key_raw_ex( &key, privateKey,
&prvkSz, publicKey, NULL, EC25519_BIG_ENDIAN + 10 )){
@ -18119,7 +18119,7 @@ static int test_wc_curve25519_export_key_raw_ex (void)
}
prvkSz = CURVE25519_KEYSIZE;
pubkSz = CURVE25519_KEYSIZE;
/* pubkSz = CURVE25519_KEYSIZE; */
if(0 != wc_curve25519_export_key_raw_ex( &key, privateKey, &prvkSz,
publicKey, &pubkSz, EC25519_BIG_ENDIAN)) {
@ -18660,8 +18660,6 @@ static int test_wc_curve25519_export_private_raw_ex (void)
int ret = 0;
#if defined(HAVE_CURVE25519)
WC_RNG rng;
curve25519_key key;
byte out[CURVE25519_KEYSIZE];
word32 outLen = sizeof(out);
@ -18670,9 +18668,6 @@ static int test_wc_curve25519_export_private_raw_ex (void)
printf(testingFmt, "wc_curve25519_export_private_raw_ex()");
ret = wc_curve25519_init(&key);
if (ret == 0) {
ret = wc_InitRng(&rng);
}
if (ret == 0) {
ret = wc_curve25519_export_private_raw_ex(&key, out, &outLen, endian);
}
@ -18715,7 +18710,6 @@ static int test_wc_curve25519_export_private_raw_ex (void)
printf(resultFmt, ret == 0 ? passed : failed);
wc_curve25519_free(&key);
wc_FreeRng(&rng);
#endif
return ret;
@ -19682,8 +19676,6 @@ static int test_wc_curve448_export_private_raw_ex (void)
int ret = 0;
#if defined(HAVE_CURVE448)
WC_RNG rng;
curve448_key key;
byte out[CURVE448_KEY_SIZE];
word32 outLen = sizeof(out);
@ -19692,9 +19684,6 @@ static int test_wc_curve448_export_private_raw_ex (void)
printf(testingFmt, "wc_curve448_export_private_raw_ex()");
ret = wc_curve448_init(&key);
if (ret == 0) {
ret = wc_InitRng(&rng);
}
if (ret == 0) {
ret = wc_curve448_export_private_raw_ex(&key, out, &outLen, endian);
}
@ -19737,7 +19726,6 @@ static int test_wc_curve448_export_private_raw_ex (void)
printf(resultFmt, ret == 0 ? passed : failed);
wc_curve448_free(&key);
wc_FreeRng(&rng);
#endif
return ret;
@ -30822,14 +30810,14 @@ static void test_wolfSSL_X509_set_version(void)
!defined(NO_CERTS) && defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_REQ)
X509* x509;
long v = 2L;
long max = INT_MAX;
long maxInt = INT_MAX;
AssertNotNull(x509 = X509_new());
/* These should pass. */
AssertTrue(wolfSSL_X509_set_version(x509, v));
AssertIntEQ(v, wolfSSL_X509_get_version(x509));
/* Fail Case: When v(long) is greater than x509->version(int). */
v = max+1;
v = maxInt+1;
AssertFalse(wolfSSL_X509_set_version(x509, v));
/* Cleanup */
X509_free(x509);
@ -33920,6 +33908,8 @@ static void test_wolfSSL_EVP_PKEY_assign(void)
WOLFSSL_EC_KEY* ecKey;
#endif
(void)pkey;
printf(testingFmt, "wolfSSL_EVP_PKEY_assign");
#ifndef NO_RSA
type = EVP_PKEY_RSA;
@ -35393,7 +35383,10 @@ static void test_wolfSSL_OCSP_SINGLERESP_get0_id()
{
#if defined(OPENSSL_ALL) && defined(HAVE_OCSP)
WOLFSSL_OCSP_SINGLERESP single;
const WOLFSSL_OCSP_CERTID* certId = wolfSSL_OCSP_SINGLERESP_get0_id(&single);
const WOLFSSL_OCSP_CERTID* certId;
XMEMSET(&single, 0, sizeof(single));
certId = wolfSSL_OCSP_SINGLERESP_get0_id(&single);
printf(testingFmt, "wolfSSL_OCSP_SINGLERESP_get0_id()");

View File

@ -324,7 +324,7 @@ static void simple_test(func_args* args)
if (cliArgs.return_code != 0) {
args->return_code = cliArgs.return_code;
#ifdef HAVE_STACK_SIZE
return (void *)0;
return (THREAD_RETURN)0;
#else
return;
#endif
@ -332,7 +332,7 @@ static void simple_test(func_args* args)
join_thread(serverThread);
if (svrArgs.return_code != 0) args->return_code = svrArgs.return_code;
#ifdef HAVE_STACK_SIZE
return (void *)0;
return (THREAD_RETURN)0;
#endif
}
#endif /* !NO_WOLFSSL_SERVER && !NO_WOLFSSL_CLIENT */

View File

@ -16229,12 +16229,12 @@ static int wc_BuildEccKeyDer(ecc_key* key, byte* output, word32 inLen,
totalSz = prvidx + pubidx + curveidx + verSz + seqSz;
if (totalSz > (int)inLen) {
#ifndef WOLFSSL_NO_MALLOC
XFREE(prv, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
if (pubIn) {
#ifndef WOLFSSL_NO_MALLOC
XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
#endif
}
#endif
return BAD_FUNC_ARG;
}

View File

@ -265,7 +265,7 @@ const byte base64Encode[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
/* make sure *i (idx) won't exceed max, store and possibly escape to out,
* raw means use e w/o decode, 0 on success */
static int CEscape(int escaped, byte e, byte* out, word32* i, word32 max,
static int CEscape(int escaped, byte e, byte* out, word32* i, word32 maxSz,
int raw, int getSzOnly)
{
int doEscape = 0;
@ -307,7 +307,7 @@ static int CEscape(int escaped, byte e, byte* out, word32* i, word32 max,
}
/* check size */
if ( (idx+needed) > max && !getSzOnly) {
if ( (idx+needed) > maxSz && !getSzOnly) {
WOLFSSL_MSG("Escape buffer max too small");
return BUFFER_E;
}

View File

@ -198,7 +198,7 @@ int wc_DeCompress(byte* out, word32 outSz, const byte* in, word32 inSz)
* is the callers responsibility on successful return.
*
* out gets set to the output buffer created, *out gets overwritten
* max is the max decompression multiplier, i.e if 2 then max out size created
* maxSz is the max decompression multiplier, i.e if 2 then max out size created
* would be 2*inSz, if set to -1 then there is no limit on out buffer size
* memoryType the memory hint to use for 'out' i.e. DYNAMIC_TYPE_TMP_BUFFER
* in compressed input buffer
@ -208,7 +208,7 @@ int wc_DeCompress(byte* out, word32 outSz, const byte* in, word32 inSz)
*
* return the decompressed size, creates and grows out buffer as needed
*/
int wc_DeCompressDynamic(byte** out, int max, int memoryType,
int wc_DeCompressDynamic(byte** out, int maxSz, int memoryType,
const byte* in, word32 inSz, int windowBits, void* heap)
{
z_stream stream;
@ -220,8 +220,8 @@ int wc_DeCompressDynamic(byte** out, int max, int memoryType,
if (out == NULL || in == NULL) {
return BAD_FUNC_ARG;
}
i = (max == 1)? 1 : 2; /* start with output buffer twice the size of input
* unless max was set to 1 */
i = (maxSz == 1)? 1 : 2; /* start with output buffer twice the size of input
* unless max was set to 1 */
stream.next_in = (Bytef*)in;
stream.avail_in = (uInt)inSz;
@ -267,7 +267,7 @@ int wc_DeCompressDynamic(byte** out, int max, int memoryType,
word32 newSz;
byte* newTmp;
if (max > 0 && i >= max) {
if (maxSz > 0 && i >= maxSz) {
WOLFSSL_MSG("Hit max decompress size!");
break;
}

View File

@ -6338,6 +6338,8 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
return err;
}
keySz = key->dp->size;
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \
defined(WOLFSSL_ASYNC_CRYPT_TEST)
if (key->asyncDev.marker == WOLFSSL_ASYNC_MARKER_ECC) {

View File

@ -1913,7 +1913,7 @@ WOLFSSL_API int wolfSSL_EVP_PKEY_cmp(const WOLFSSL_EVP_PKEY *a, const WOLFSSL_EV
break;
#endif /* HAVE_ECC */
default:
break;
return ret;
} /* switch (a->type) */
/* check size */

View File

@ -52,11 +52,11 @@ static const byte ed25519_order[F25519_SIZE] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10
};
/*Arithmetic modulo the group order m = 2^252 +
/*Arithmetic modulo the group order mod = 2^252 +
27742317777372353535851937790883648493 =
7237005577332262213973186563042994240857116359379907606001950938285454250989 */
static const word32 m[32] = {
static const word32 mod[32] = {
0xED,0xD3,0xF5,0x5C,0x1A,0x63,0x12,0x58,0xD6,0x9C,0xF7,0xA2,0xDE,0xF9,
0xDE,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x10
@ -111,7 +111,7 @@ static void reduce_add_sub(word32 *r)
for(i=0;i<32;i++)
{
pb += m[i];
pb += mod[i];
b = lt(r[i],pb);
t[i] = r[i]-pb+(b<<8);
pb = b;
@ -149,7 +149,7 @@ static void barrett_reduce(word32* r, word32 x[64])
for(i=0;i<33;i++)r1[i] = x[i];
for(i=0;i<32;i++)
for(j=0;j<33;j++)
if(i+j < 33) r2[i+j] += m[i]*q3[j];
if(i+j < 33) r2[i+j] += mod[i]*q3[j];
for(i=0;i<32;i++)
{

View File

@ -312,7 +312,7 @@ int wolfSSL_init_memory_heap(WOLFSSL_HEAP* heap)
}
int wc_LoadStaticMemory(WOLFSSL_HEAP_HINT** pHint,
unsigned char* buf, unsigned int sz, int flag, int max)
unsigned char* buf, unsigned int sz, int flag, int maxSz)
{
int ret;
WOLFSSL_HEAP* heap;
@ -362,16 +362,16 @@ int wc_LoadStaticMemory(WOLFSSL_HEAP_HINT** pHint,
/* determine what max applies too */
if ((flag & WOLFMEM_IO_POOL) || (flag & WOLFMEM_IO_POOL_FIXED)) {
heap->maxIO = max;
heap->maxIO = maxSz;
}
else { /* general memory used in handshakes */
heap->maxHa = max;
heap->maxHa = maxSz;
}
heap->flag |= flag;
*pHint = hint;
(void)max;
(void)maxSz;
return 0;
}

View File

@ -1748,7 +1748,6 @@ enum {
* and auto retry */
SSL_MODE_RELEASE_BUFFERS = -1, /* For libwebsockets build. No current use. */
BIO_FLAGS_BASE64_NO_NL = 1,
BIO_CLOSE = 1,
BIO_NOCLOSE = 0,

View File

@ -492,8 +492,6 @@ WC_NORETURN void
#endif
err_sys(const char* msg)
{
printf("wolfSSL error: %s\n", msg);
#if !defined(__GNUC__)
/* scan-build (which pretends to be gnuc) can get confused and think the
* msg pointer can be null even when hardcoded and then it won't exit,
@ -504,6 +502,8 @@ err_sys(const char* msg)
if (msg)
#endif
{
printf("wolfSSL error: %s\n", msg);
XEXIT_T(EXIT_FAILURE);
}
}
@ -516,12 +516,6 @@ WC_NORETURN void
#endif
err_sys_with_errno(const char* msg)
{
#if defined(HAVE_STRING_H) && defined(HAVE_ERRNO_H)
printf("wolfSSL error: %s: %s\n", msg, strerror(errno));
#else
printf("wolfSSL error: %s\n", msg);
#endif
#if !defined(__GNUC__)
/* scan-build (which pretends to be gnuc) can get confused and think the
* msg pointer can be null even when hardcoded and then it won't exit,
@ -532,6 +526,12 @@ err_sys_with_errno(const char* msg)
if (msg)
#endif
{
#if defined(HAVE_STRING_H) && defined(HAVE_ERRNO_H)
printf("wolfSSL error: %s: %s\n", msg, strerror(errno));
#else
printf("wolfSSL error: %s\n", msg);
#endif
XEXIT_T(EXIT_FAILURE);
}
}
@ -600,7 +600,7 @@ static WC_INLINE int mygetopt(int argc, char** argv, const char* optstring)
/* The C++ strchr can return a different value */
cp = (char*)strchr(optstring, c);
if (cp == NULL || c == ':' || 'c' == ';')
if (cp == NULL || c == ':' || c == ';')
return '?';
cp++;
@ -1292,8 +1292,8 @@ static WC_INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
func_args* args, word16 port, int useAnyAddr,
int udp, int sctp, int ready_file, int do_listen)
{
SOCKADDR_IN_T client;
socklen_t client_len = sizeof(client);
SOCKADDR_IN_T client_addr;
socklen_t client_len = sizeof(client_addr);
tcp_ready* ready = NULL;
(void) ready; /* Account for case when "ready" is not used */
@ -1350,7 +1350,7 @@ static WC_INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
}
}
*clientfd = accept(*sockfd, (struct sockaddr*)&client,
*clientfd = accept(*sockfd, (struct sockaddr*)&client_addr,
(ACCEPT_THIRD_T)&client_len);
if(WOLFSSL_SOCKET_IS_INVALID(*clientfd)) {
err_sys_with_errno("tcp accept failed");
@ -1605,7 +1605,7 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
{
int ret;
long int fileSz;
XFILE file;
XFILE lFile;
if (fname == NULL || buf == NULL || bufLen == NULL)
return BAD_FUNC_ARG;
@ -1615,15 +1615,15 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
*bufLen = 0;
/* open file (read-only binary) */
file = XFOPEN(fname, "rb");
if (!file) {
lFile = XFOPEN(fname, "rb");
if (!lFile) {
printf("Error loading %s\n", fname);
return BAD_PATH_ERROR;
}
fseek(file, 0, SEEK_END);
fileSz = (int)ftell(file);
rewind(file);
fseek(lFile, 0, SEEK_END);
fileSz = (int)ftell(lFile);
rewind(lFile);
if (fileSz > 0) {
*bufLen = (size_t)fileSz;
*buf = (byte*)malloc(*bufLen);
@ -1632,7 +1632,7 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
printf("Error allocating %lu bytes\n", (unsigned long)*bufLen);
}
else {
size_t readLen = fread(*buf, *bufLen, 1, file);
size_t readLen = fread(*buf, *bufLen, 1, lFile);
/* check response code */
ret = (readLen > 0) ? 0 : -1;
@ -1641,7 +1641,7 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
else {
ret = BUFFER_E;
}
fclose(file);
fclose(lFile);
return ret;
}
@ -2002,11 +2002,11 @@ static WC_INLINE void CaCb(unsigned char* der, int sz, int type)
{
#if !defined(NO_FILESYSTEM) || defined(FORCE_BUFFER_TEST)
int depth, res;
XFILE file;
XFILE keyFile;
for(depth = 0; depth <= MAX_WOLF_ROOT_DEPTH; depth++) {
file = XFOPEN(ntruKeyFile, "rb");
if (file != NULL) {
fclose(file);
keyFile = XFOPEN(ntruKeyFile, "rb");
if (keyFile != NULL) {
fclose(keyFile);
return depth;
}
#ifdef USE_WINDOWS_API
@ -2052,7 +2052,7 @@ struct stack_size_debug_context {
* ./configure --enable-stacksize=verbose [...]
*/
static void *debug_stack_size_verbose_shim(struct stack_size_debug_context *shim_args) {
static THREAD_RETURN debug_stack_size_verbose_shim(struct stack_size_debug_context *shim_args) {
StackSizeCheck_myStack = shim_args->myStack;
StackSizeCheck_stackSize = shim_args->stackSize;
StackSizeCheck_stackSizeHWM_ptr = shim_args->stackSizeHWM_ptr;
@ -2066,7 +2066,9 @@ static WC_INLINE int StackSizeSetOffset(const char *funcname, void *p)
StackSizeCheck_stackOffsetPointer = p;
printf("setting stack relative offset reference mark in %s to +%ld\n", funcname, (char *)(StackSizeCheck_myStack + StackSizeCheck_stackSize) - (char *)p);
printf("setting stack relative offset reference mark in %s to +%lu\n",
funcname, (unsigned long)((char*)(StackSizeCheck_myStack +
StackSizeCheck_stackSize) - (char *)p));
return 0;
}
@ -2208,11 +2210,13 @@ static WC_INLINE int StackSizeCheck(func_args* args, thread_func tf)
free(myStack);
#ifdef HAVE_STACK_SIZE_VERBOSE
printf("stack used = %lu\n", StackSizeCheck_stackSizeHWM > (stackSize - i) ? StackSizeCheck_stackSizeHWM : (stackSize - i));
printf("stack used = %lu\n", StackSizeCheck_stackSizeHWM > (stackSize - i)
? (unsigned long)StackSizeCheck_stackSizeHWM
: (unsigned long)(stackSize - i));
#else
{
size_t used = stackSize - i;
printf("stack used = %lu\n", used);
printf("stack used = %lu\n", (unsigned long)used);
}
#endif
@ -2288,11 +2292,14 @@ static WC_INLINE int StackSizeCheck_reap(pthread_t threadId, void *stack_context
free(shim_args->myStack);
#ifdef HAVE_STACK_SIZE_VERBOSE
printf("stack used = %lu\n", *shim_args->stackSizeHWM_ptr > (shim_args->stackSize - i) ? *shim_args->stackSizeHWM_ptr : (shim_args->stackSize - i));
printf("stack used = %lu\n",
*shim_args->stackSizeHWM_ptr > (shim_args->stackSize - i)
? (unsigned long)*shim_args->stackSizeHWM_ptr
: (unsigned long)(shim_args->stackSize - i));
#else
{
size_t used = shim_args->stackSize - i;
printf("stack used = %lu\n", used);
printf("stack used = %lu\n", (unsigned long)used);
}
#endif
free(shim_args);

View File

@ -678,17 +678,17 @@ extern void uITRON4_free(void *p) ;
/* static char* gets(char *buff); */
static char* fgets(char *buff, int sz, XFILE fp) {
char * p = buff;
*p = '\0';
char * s = buff;
*s = '\0';
while (1) {
*p = tm_getchar(-1);
tm_putchar(*p);
if (*p == '\r') {
*s = tm_getchar(-1);
tm_putchar(*s);
if (*s == '\r') {
tm_putchar('\n');
*p = '\0';
*s = '\0';
break;
}
p++;
s++;
}
return buff;
}