Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions src/crypto/clu_evp_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,36 @@ int wolfCLU_evp_crypto(const WOLFSSL_EVP_CIPHER* cphr, char* mode, byte* pwdKey,
in = wolfSSL_BIO_new_file(fileIn, "rb");
if (in != NULL && !enc && isBase64) {
word32 decodeSz;
int bioSz;

decodeSz = wolfSSL_BIO_get_len(in);
decodedBase64 = (byte*)XMALLOC(decodeSz, HEAP_HINT,
DYNAMIC_TYPE_TMP_BUFFER);
if (decodedBase64 == NULL) {
if ((bioSz = wolfSSL_BIO_get_len(in)) <= 0) {
ret = WOLFCLU_FATAL_ERROR;
}
else {
if (wolfSSL_BIO_read(in, decodedBase64, decodeSz) !=
(int)decodeSz) {
decodeSz = (word32)bioSz;
decodedBase64 = (byte*)XMALLOC(bioSz, HEAP_HINT,
DYNAMIC_TYPE_TMP_BUFFER);
if (decodedBase64 == NULL) {
ret = WOLFCLU_FATAL_ERROR;
}
else {
if (wolfSSL_BIO_read(in, decodedBase64, bioSz) !=
bioSz) {
ret = WOLFCLU_FATAL_ERROR;
}

if (ret == WOLFCLU_SUCCESS &&
Base64_Decode(decodedBase64, decodeSz,
decodedBase64, &decodeSz) != 0) {
ret = WOLFCLU_FATAL_ERROR;
}
if (ret == WOLFCLU_SUCCESS &&
Base64_Decode(decodedBase64, bioSz,
decodedBase64, &decodeSz) != 0) {
ret = WOLFCLU_FATAL_ERROR;
}

if (ret == WOLFCLU_SUCCESS) {
wolfSSL_BIO_free(in);
in = wolfSSL_BIO_new_mem_buf(decodedBase64, decodeSz);
if (ret == WOLFCLU_SUCCESS) {
wolfSSL_BIO_free(in);
in = wolfSSL_BIO_new_mem_buf(decodedBase64, decodeSz);
}
}
}

}
}
else {
Expand Down
6 changes: 3 additions & 3 deletions src/dh/clu_dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ int wolfCLU_DhParamSetup(int argc, char** argv)
if (ret == WOLFCLU_SUCCESS && bioIn != NULL) {
DerBuffer* pDer = NULL;
byte* in = NULL;
word32 inSz = 0;
int inSz = 0;
word32 idx = 0;

inSz = wolfSSL_BIO_get_len(bioIn);
Expand All @@ -500,7 +500,7 @@ int wolfCLU_DhParamSetup(int argc, char** argv)
}

/* der should always be smaller then pem but check just in case */
if (ret == WOLFCLU_SUCCESS && inSz < pDer->length) {
if (ret == WOLFCLU_SUCCESS && (word32)inSz < pDer->length) {
ret = WOLFCLU_FATAL_ERROR;
}

Expand All @@ -510,7 +510,7 @@ int wolfCLU_DhParamSetup(int argc, char** argv)
}

if (ret == WOLFCLU_SUCCESS &&
wc_DhKeyDecode(in, &idx, &dh, inSz) != 0) {
wc_DhKeyDecode(in, &idx, &dh, (int)inSz) != 0) {
wolfCLU_LogError("Unable to decode input params");
ret = WOLFCLU_FATAL_ERROR;
}
Expand Down
11 changes: 9 additions & 2 deletions src/ocsp/clu_ocsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static int ocspClient(OcspClientConfig* config)
typedef struct IndexEntry {
char status;
time_t revocationTime;
char serial[64];
Comment thread
philljj marked this conversation as resolved.
char serial[2 * EXTERNAL_SERIAL_SIZE + 1];
struct IndexEntry* next;
} IndexEntry;

Expand Down Expand Up @@ -466,7 +466,14 @@ static IndexEntry* parseIndexFile(const char* filename)
}
break;
case 3: /* Serial (hex) */
if (XSTRLEN(field) > sizeof(entry->serial)-1) {
wolfCLU_LogError("Field %s too long to fit in entry "
"with max size %lu", field,
(unsigned long)(sizeof(entry->serial)-1));
break;
}
XSTRNCPY(entry->serial, field, sizeof(entry->serial) - 1);
entry->serial[sizeof(entry->serial) - 1] = '\0';
break;
}
fieldNum++;
Expand All @@ -478,7 +485,7 @@ static IndexEntry* parseIndexFile(const char* filename)
entry = NULL;
continue;
}

/* For revoked certificates, revocationTime must be valid */
if (entry->status == 'R' && entry->revocationTime == (time_t)-1) {
wolfCLU_LogError("Invalid revocation time for serial %s", entry->serial);
Expand Down
Loading
Loading