From 2667b8b5424a8380bd2a04515ef1054e218beffe Mon Sep 17 00:00:00 2001 From: toddouska Date: Mon, 4 Mar 2013 11:36:07 -0800 Subject: [PATCH 1/3] fix base64 decode white space loop --- ctaocrypt/src/coding.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ctaocrypt/src/coding.c b/ctaocrypt/src/coding.c index d5afdcbe6..a9f374543 100644 --- a/ctaocrypt/src/coding.c +++ b/ctaocrypt/src/coding.c @@ -104,16 +104,18 @@ int Base64_Decode(const byte* in, word32 inLen, byte* out, word32* outLen) break; inLen -= 4; - if (in[j] == ' ' || in[j] == '\r' || in[j] == '\n') { + if (inLen && (in[j] == ' ' || in[j] == '\r' || in[j] == '\n')) { byte endLine = in[j++]; inLen--; - while (endLine == ' ') { /* allow trailing whitespace */ + while (inLen && endLine == ' ') { /* allow trailing whitespace */ endLine = in[j++]; inLen--; } if (endLine == '\r') { - endLine = in[j++]; - inLen--; + if (inLen) { + endLine = in[j++]; + inLen--; + } } if (endLine != '\n') { CYASSL_MSG("Bad end of line in Base64 Decode"); From 12371d1c3bb615fc6a86611a790dadb288cad1b1 Mon Sep 17 00:00:00 2001 From: toddouska Date: Mon, 4 Mar 2013 12:18:21 -0800 Subject: [PATCH 2/3] fix windows build warnings --- src/internal.c | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/src/internal.c b/src/internal.c index 01610c56c..e4762e4a8 100644 --- a/src/internal.c +++ b/src/internal.c @@ -2503,23 +2503,12 @@ static void BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) #endif Sha sha = ssl->hashSha; #ifndef NO_SHA256 - Sha256 sha256; + Sha256 sha256 = ssl->hashSha256; #endif #ifdef CYASSL_SHA384 - Sha384 sha384; + Sha384 sha384 = ssl->hashSha384; #endif - if (IsAtLeastTLSv1_2(ssl)) { - #ifndef NO_SHA256 - InitSha256(&sha256); - sha256 = ssl->hashSha256; - #endif - #ifdef CYASSL_SHA384 - InitSha384(&sha384); - sha384 = ssl->hashSha384; - #endif - } - if (ssl->options.tls) BuildTlsFinished(ssl, hashes, sender); #ifndef NO_MD5 @@ -2536,10 +2525,10 @@ static void BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) ssl->hashSha = sha; if (IsAtLeastTLSv1_2(ssl)) { #ifndef NO_SHA256 - ssl->hashSha256 = sha256; + ssl->hashSha256 = sha256; #endif #ifdef CYASSL_SHA384 - ssl->hashSha384 = sha384; + ssl->hashSha384 = sha384; #endif } } @@ -4535,23 +4524,12 @@ static void BuildCertHashes(CYASSL* ssl, Hashes* hashes) Md5 md5 = ssl->hashMd5; Sha sha = ssl->hashSha; #ifndef NO_SHA256 - Sha256 sha256; + Sha256 sha256 = ssl->hashSha256; #endif #ifdef CYASSL_SHA384 - Sha384 sha384; + Sha384 sha384 = ssl->hashSha384; #endif - if (IsAtLeastTLSv1_2(ssl)) { - #ifndef NO_SHA256 - InitSha256(&sha256); - sha256 = ssl->hashSha256; - #endif - #ifdef CYASSL_SHA384 - InitSha384(&sha384); - sha384 = ssl->hashSha384; - #endif - } - if (ssl->options.tls) { Md5Final(&ssl->hashMd5, hashes->md5); ShaFinal(&ssl->hashSha, hashes->sha); @@ -6092,7 +6070,7 @@ int SetCipherList(Suites* s, const char* list) s->hashSigAlgo[idx++] = rsa_sa_algo; } - s->hashSigAlgoSz = idx; + s->hashSigAlgoSz = (word16)idx; } return ret; From 43b83008967893d92cb5d59864316c1aa564899e Mon Sep 17 00:00:00 2001 From: toddouska Date: Mon, 4 Mar 2013 12:30:36 -0800 Subject: [PATCH 3/3] windows shadow fix --- cyassl/ctaocrypt/error.h | 2 +- cyassl/error.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cyassl/ctaocrypt/error.h b/cyassl/ctaocrypt/error.h index 204600721..c7b24eb83 100644 --- a/cyassl/ctaocrypt/error.h +++ b/cyassl/ctaocrypt/error.h @@ -107,7 +107,7 @@ enum { }; -CYASSL_API void CTaoCryptErrorString(int error, char* buffer); +CYASSL_API void CTaoCryptErrorString(int err, char* buff); #ifdef __cplusplus diff --git a/cyassl/error.h b/cyassl/error.h index 2f222051a..04bb689a8 100644 --- a/cyassl/error.h +++ b/cyassl/error.h @@ -130,7 +130,7 @@ enum CyaSSL_ErrorCodes { CYASSL_LOCAL -void SetErrorString(int error, char* buffer); +void SetErrorString(int err, char* buff); #ifdef __cplusplus