Fix such as "for loop initial declaration"

This commit is contained in:
TakayukiMatsuo
2021-02-23 02:29:37 +09:00
parent 49d1b859d4
commit b495e12179
3 changed files with 25 additions and 23 deletions

View File

@ -2610,6 +2610,7 @@ static void test_wolfSSL_EVP_EncodeUpdate(void)
total += outl;
AssertIntNE(total,0);
AssertIntNE(outl,0);
AssertIntEQ(XSTRNCMP(
(const char*)encOutBuff,(const char*)enc2,sizeof(enc2) ),0);

View File

@ -6880,12 +6880,12 @@ int wolfSSL_EVP_get_hashinfo(const WOLFSSL_EVP_MD* evp,
/* Base64 encoding APIs */
#if defined(WOLFSSL_BASE64_ENCODE) || defined(WOLFSSL_BASE64_DECODE)
static WOLFSSL_EVP_ENCODE_CTX* wolfSSL_EVP_ENCODE_CTX_new_ex(void* heap);
WOLFSSL_EVP_ENCODE_CTX* wolfSSL_EVP_ENCODE_CTX_new(void)
static struct WOLFSSL_EVP_ENCODE_CTX* wolfSSL_EVP_ENCODE_CTX_new_ex(void* heap);
struct WOLFSSL_EVP_ENCODE_CTX* wolfSSL_EVP_ENCODE_CTX_new(void)
{
return wolfSSL_EVP_ENCODE_CTX_new_ex(NULL);
}
static WOLFSSL_EVP_ENCODE_CTX* wolfSSL_EVP_ENCODE_CTX_new_ex(void* heap)
static struct WOLFSSL_EVP_ENCODE_CTX* wolfSSL_EVP_ENCODE_CTX_new_ex(void* heap)
{
WOLFSSL_ENTER("wolfSSL_EVP_ENCODE_CTX_new");
WOLFSSL_EVP_ENCODE_CTX* ctx = (WOLFSSL_EVP_ENCODE_CTX*)XMALLOC( sizeof(WOLFSSL_EVP_ENCODE_CTX),heap,DYNAMIC_TYPE_OPENSSL );
@ -7058,6 +7058,7 @@ int wolfSSL_EVP_DecodeUpdate(WOLFSSL_EVP_ENCODE_CTX* ctx,
word32 inLen;
int res;
int pad = 0;
int i;
WOLFSSL_ENTER("wolfSSL_EVP_DecodeUpdate");
@ -7081,21 +7082,21 @@ int wolfSSL_EVP_DecodeUpdate(WOLFSSL_EVP_ENCODE_CTX* ctx,
a block(4bytes) for decoding*/
if( ctx->remaining > 0 && inl > 0) {
int cpysz;
unsigned char e;
unsigned char e0;
cpysz = min( (BASE64_DECODE_BLOCK_SIZE - ctx->remaining), inl );
for (int i = 0; cpysz > 0 && inLen > 0;i++) {
for ( i = 0; cpysz > 0 && inLen > 0;i++) {
if ((res = Base64_SkipNewline(in, &inLen, &j))
== ASN_INPUT_E) {
return -1; /* detected an illegal char in input */
}
e = in[j++];
e0 = in[j++];
if (e == '=')
if (e0 == '=')
pad = 1;
*(ctx->data + ctx->remaining + i) = e;
*(ctx->data + ctx->remaining + i) = e0;
inLen--;
cpysz--;
}
@ -7202,18 +7203,18 @@ int wolfSSL_EVP_DecodeUpdate(WOLFSSL_EVP_ENCODE_CTX* ctx,
if (inLen > 0) {
XMEMSET(ctx->data, 0, sizeof(ctx->data));
int i = 0;
unsigned char e;
i = 0;
unsigned char el;
while ( inLen > 0) {
e = in[j++];
if (e== '\n' || e == '\r' || e == ' ') {
el = in[j++];
if (el== '\n' || el == '\r' || el == ' ') {
inLen--;
continue;
}
if (e == '=') {
if (el == '=') {
pad = 1;
}
ctx->data[i++] = e;
ctx->data[i++] = el;
ctx->remaining++;
inLen--;
}
@ -7225,15 +7226,15 @@ int wolfSSL_EVP_DecodeUpdate(WOLFSSL_EVP_ENCODE_CTX* ctx,
}
/* if the last data is '\n', remove it */
char e = in[j - 1];
if (e == '\n') {
e = (in[j - 2]);
if (e == '=')
char es = in[j - 1];
if (es == '\n') {
es = (in[j - 2]);
if (es == '=')
return 0;
else
return 1;
}
if (e == '=')
if (es == '=')
return 0;
else
return 1;

View File

@ -382,14 +382,14 @@ struct WOLFSSL_EVP_PKEY_CTX {
#define BASE64_ENCODED_BLOCK_SIZE 64
#define BASE64_DECODE_BLOCK_SIZE 4
typedef struct WOLFSSL_EVP_ENCODE_CTX
{
struct WOLFSSL_EVP_ENCODE_CTX {
void* heap;
int remaining; /* num of bytes in data[] */
byte data[128]; /* storage for unprocessed raw data */
}WOLFSSL_EVP_ENCODE_CTX;
};
typedef struct WOLFSSL_EVP_ENCODE_CTX WOLFSSL_EVP_ENCODE_CTX;
WOLFSSL_API WOLFSSL_EVP_ENCODE_CTX* wolfSSL_EVP_ENCODE_CTX_new(void);
WOLFSSL_API struct WOLFSSL_EVP_ENCODE_CTX* wolfSSL_EVP_ENCODE_CTX_new(void);
WOLFSSL_API void wolfSSL_EVP_ENCODE_CTX_free(WOLFSSL_EVP_ENCODE_CTX* ctx);
#endif /* WOLFSSL_BASE64_ENCODE || WOLFSSL_BASE64_DECODE */