Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/wp_dec_pem2der.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ static int wp_pem2der_decode(wp_Pem2Der* ctx, OSSL_CORE_BIO* coreBio,
else if (data == NULL) {
done = 1;
}
if (!done) {
if (ok && !done) {
idx += wp_pem2der_find_header(data + idx, len - idx);
/* No header means nothing to do. */
if (idx == len) {
Expand Down
20 changes: 15 additions & 5 deletions src/wp_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,18 +1276,21 @@ int wp_read_der_bio(WOLFPROV_CTX *provctx, OSSL_CORE_BIO *coreBio, unsigned char
while (ok && (readLen > 0)) {
readLen = BIO_read(bio, buf, sizeof(buf));
if (readLen < -1) {
WOLFPROV_MSG(WP_LOG_COMP_PROVIDER, "BIO_read error (%d) in %s:%d", readLen, __FILE__, __LINE__);
WOLFPROV_MSG(WP_LOG_COMP_PROVIDER, "BIO_read error (%ld) in %s:%d", readLen, __FILE__, __LINE__);
ok = 0;
}
if (ok && (readLen > 0) &&
((uint64_t)*len + (uint64_t)readLen > (uint64_t)UINT32_MAX)) {
(!WP_FITS_WORD32((uint64_t)*len + (uint64_t)readLen))) {
WOLFPROV_MSG(WP_LOG_COMP_PROVIDER,
"Length overflow (%u + %ld) in %s:%d", *len, readLen, __FILE__,
__LINE__);
ok = 0;
}
if (ok && (readLen > 0)) {
/* Reallocate for new data. */
p = OPENSSL_realloc(*data, *len + readLen);
if (p == NULL) {
WOLFPROV_MSG(WP_LOG_COMP_PROVIDER, "OPENSSL_realloc error (%d) in %s:%d", readLen, __FILE__, __LINE__);
WOLFPROV_MSG(WP_LOG_COMP_PROVIDER, "OPENSSL_realloc error (%ld) in %s:%d", readLen, __FILE__, __LINE__);
ok = 0;
}
}
Expand Down Expand Up @@ -1335,16 +1338,23 @@ int wp_read_pem_bio(WOLFPROV_CTX *provctx, OSSL_CORE_BIO *coreBio,
/* Read a line at a time. */
readLen = BIO_gets(bio, buf, sizeof(buf));
if (readLen < -1) {
WOLFPROV_MSG(WP_LOG_COMP_PROVIDER, "BIO_read error (%d) in %s:%d",
WOLFPROV_MSG(WP_LOG_COMP_PROVIDER, "BIO_gets error (%ld) in %s:%d",
readLen, __FILE__, __LINE__);
ok = 0;
}
if (ok && (readLen > 0) &&
(!WP_FITS_WORD32((uint64_t)*len + (uint64_t)readLen))) {
WOLFPROV_MSG(WP_LOG_COMP_PROVIDER,
"Length overflow (%u + %ld) in %s:%d", *len, readLen, __FILE__,
__LINE__);
ok = 0;
}
if (ok && (readLen > 0)) {
/* Reallocate for new data. */
p = OPENSSL_realloc(*data, *len + readLen);
if (p == NULL) {
WOLFPROV_MSG(WP_LOG_COMP_PROVIDER,
"OPENSSL_realloc error (%d) in %s:%d", readLen, __FILE__,
"OPENSSL_realloc error (%ld) in %s:%d", readLen, __FILE__,
__LINE__);
ok = 0;
}
Expand Down
Loading