From 0867da038f4d7434e9d1b89c488f8dc715951a0f Mon Sep 17 00:00:00 2001 From: Todd A Ouska Date: Tue, 12 Jul 2011 16:43:40 -0700 Subject: [PATCH] Warning Level 4 MSVC fixes except while (1) which causes bugs sometimes if for(;;) is used instead --- ctaocrypt/src/asn.c | 10 ++-------- cyassl.vcproj | 2 +- src/cyassl_int.c | 14 ++++++-------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/ctaocrypt/src/asn.c b/ctaocrypt/src/asn.c index 8890810cb..261dc5ea7 100644 --- a/ctaocrypt/src/asn.c +++ b/ctaocrypt/src/asn.c @@ -277,13 +277,14 @@ static int GetLength(const byte* input, word32* inOutIdx, int* len, { int length = 0; word32 i = *inOutIdx; + byte b; if ( (i+1) > maxIdx) { /* for first read */ CYASSL_MSG("GetLength bad index on input"); return BUFFER_E; } - byte b = input[i++]; + b = input[i++]; if (b >= ASN_LONG_LENGTH) { word32 bytes = b & 0x7F; @@ -477,7 +478,6 @@ static int GetAlgoId(const byte* input, word32* inOutIdx, word32* oid, int RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key, word32 inSz) { - word32 begin = *inOutIdx; int version, length; if (GetSequence(input, inOutIdx, &length, inSz) < 0) @@ -796,7 +796,6 @@ int ToTraditionalEnc(byte* input, word32 sz,const char* password,int passwordSz) int RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key, word32 inSz) { - word32 begin = *inOutIdx; int length; byte b; @@ -862,7 +861,6 @@ int RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key, int DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key, word32 inSz) { - word32 begin = *inOutIdx; int length; if (GetSequence(input, inOutIdx, &length, inSz) < 0) @@ -909,7 +907,6 @@ int DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g, word32 gSz) int DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey* key, word32 inSz) { - word32 begin = *inOutIdx; int length; if (GetSequence(input, inOutIdx, &length, inSz) < 0) @@ -928,7 +925,6 @@ int DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey* key, int DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, DsaKey* key, word32 inSz) { - word32 begin = *inOutIdx; int length, version; if (GetSequence(input, inOutIdx, &length, inSz) < 0) @@ -994,7 +990,6 @@ void FreeDecodedCert(DecodedCert* cert) static int GetCertHeader(DecodedCert* cert) { int ret = 0, version, len; - word32 begin = cert->srcIdx; byte serialTmp[EXTERNAL_SERIAL_SIZE]; mp_int mpi; @@ -3193,7 +3188,6 @@ int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen, mp_int* r, mp_int* s) int EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key, word32 inSz) { - word32 begin = *inOutIdx; word32 oid = 0; int version, length; int privSz, pubSz; diff --git a/cyassl.vcproj b/cyassl.vcproj index c08b1ce63..0a5be4773 100755 --- a/cyassl.vcproj +++ b/cyassl.vcproj @@ -47,7 +47,7 @@ BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" DebugInformationFormat="4" /> hashMd5; Sha sha = ssl->hashSha; - const int isTls1_2 = IsAtLeastTLSv1_2(ssl); #ifndef NO_SHA256 - Sha256 sha256; - if (isTls1_2) + Sha256 sha256 = {0}; + if (IsAtLeastTLSv1_2(ssl)) sha256 = ssl->hashSha256; #endif @@ -1427,7 +1426,7 @@ static void BuildFinished(SSL* ssl, Hashes* hashes, const byte* sender) ssl->hashMd5 = md5; ssl->hashSha = sha; #ifndef NO_SHA256 - if (isTls1_2) + if (IsAtLeastTLSv1_2(ssl)) ssl->hashSha256 = sha256; #endif } @@ -2481,10 +2480,9 @@ static void BuildCertHashes(SSL* ssl, Hashes* hashes) /* store current states, building requires get_digest which resets state */ Md5 md5 = ssl->hashMd5; Sha sha = ssl->hashSha; - const int isTls1_2 = IsAtLeastTLSv1_2(ssl); #ifndef NO_SHA256 /* for possible future changes */ - Sha256 sha256; - if (isTls1_2) + Sha256 sha256 = {0}; + if (IsAtLeastTLSv1_2(ssl)) sha256 = ssl->hashSha256; #endif @@ -2501,7 +2499,7 @@ static void BuildCertHashes(SSL* ssl, Hashes* hashes) ssl->hashMd5 = md5; ssl->hashSha = sha; #ifndef NO_SHA256 - if (isTls1_2) + if (IsAtLeastTLSv1_2(ssl)) ssl->hashSha256 = sha256; #endif }