Merge pull request #1221 from SparkiDev/warn_fix1

Fix warnings and g++ casting error
This commit is contained in:
dgarske
2017-11-09 09:35:54 -08:00
committed by GitHub
2 changed files with 14 additions and 23 deletions

View File

@@ -288,16 +288,17 @@ WOLFSSL_CTX* wolfSSL_CTX_new_ex(WOLFSSL_METHOD* method, void* heap)
wolfSSL_CTX_free(ctx); wolfSSL_CTX_free(ctx);
ctx = NULL; ctx = NULL;
} }
#if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) \ #if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) \
&& !defined(NO_SHA256) && !defined(WC_NO_RNG) && !defined(NO_SHA256) && !defined(WC_NO_RNG)
ctx->srp = (Srp*) XMALLOC(sizeof(Srp), heap, DYNAMIC_TYPE_SRP); else {
if (ctx->srp == NULL){ ctx->srp = (Srp*) XMALLOC(sizeof(Srp), heap, DYNAMIC_TYPE_SRP);
WOLFSSL_MSG("Init CTX failed"); if (ctx->srp == NULL){
wolfSSL_CTX_free(ctx); WOLFSSL_MSG("Init CTX failed");
return NULL; wolfSSL_CTX_free(ctx);
return NULL;
}
XMEMSET(ctx->srp, 0, sizeof(Srp));
} }
XMEMSET(ctx->srp, 0, sizeof(Srp));
#endif #endif
} }
else { else {
@@ -11177,7 +11178,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
int wolfSSL_CTX_set_srp_username(WOLFSSL_CTX* ctx, char* username) int wolfSSL_CTX_set_srp_username(WOLFSSL_CTX* ctx, char* username)
{ {
int r = 0; int r = 0;
int srp_side = 0; SrpSide srp_side = SRP_CLIENT_SIDE;
WC_RNG rng; WC_RNG rng;
byte salt[SRP_SALT_SIZE]; byte salt[SRP_SALT_SIZE];
@@ -11290,9 +11291,8 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
if (ctx->srp_password != NULL) if (ctx->srp_password != NULL)
XFREE(ctx->srp_password,ctx->heap, DYNAMIC_TYPE_SRP); XFREE(ctx->srp_password,ctx->heap, DYNAMIC_TYPE_SRP);
ctx->srp_password = XMALLOC(XSTRLEN(password) + 1, ctx->srp_password = (byte*)XMALLOC(XSTRLEN(password) + 1, ctx->heap,
ctx->heap, DYNAMIC_TYPE_SRP);
DYNAMIC_TYPE_SRP);
if (ctx->srp_password == NULL){ if (ctx->srp_password == NULL){
WOLFSSL_MSG("memory allocation error"); WOLFSSL_MSG("memory allocation error");
return SSL_FAILURE; return SSL_FAILURE;

View File

@@ -7855,7 +7855,7 @@ int wc_AesXtsEncrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz,
word32 blocks = (sz / AES_BLOCK_SIZE); word32 blocks = (sz / AES_BLOCK_SIZE);
Aes *aes, *tweak; Aes *aes, *tweak;
if (xaes == NULL || out == NULL) { if (xaes == NULL || out == NULL || in == NULL) {
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
} }
@@ -7866,10 +7866,6 @@ int wc_AesXtsEncrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz,
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
} }
if (in == NULL && sz > 0) {
return BAD_FUNC_ARG;
}
if (blocks > 0) { if (blocks > 0) {
byte tmp[AES_BLOCK_SIZE]; byte tmp[AES_BLOCK_SIZE];
@@ -7896,7 +7892,6 @@ int wc_AesXtsEncrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz,
if (carry) { if (carry) {
tmp[0] ^= GF_XTS; tmp[0] ^= GF_XTS;
} }
carry = 0;
in += AES_BLOCK_SIZE; in += AES_BLOCK_SIZE;
out += AES_BLOCK_SIZE; out += AES_BLOCK_SIZE;
@@ -7948,7 +7943,7 @@ int wc_AesXtsDecrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz,
word32 blocks = (sz / AES_BLOCK_SIZE); word32 blocks = (sz / AES_BLOCK_SIZE);
Aes *aes, *tweak; Aes *aes, *tweak;
if (xaes == NULL || out == NULL) { if (xaes == NULL || out == NULL || in == NULL) {
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
} }
@@ -7959,10 +7954,6 @@ int wc_AesXtsDecrypt(XtsAes* xaes, byte* out, const byte* in, word32 sz,
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
} }
if (in == NULL && sz > 0) {
return BAD_FUNC_ARG;
}
if (blocks > 0) { if (blocks > 0) {
word32 j; word32 j;
byte carry = 0; byte carry = 0;