Skip to content

Commit

Permalink
Merge pull request #7517 from bandi13/bugFixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
dgarske committed May 13, 2024
2 parents d39ab76 + c5773f5 commit 568fda0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/pk.c
Original file line number Diff line number Diff line change
Expand Up @@ -15745,8 +15745,7 @@ int wolfSSL_PEM_read_bio(WOLFSSL_BIO* bio, char **name, char **header,
* @param [in] header Encryption header.
* @param [in] data DER data.
* @param [in] len Length of DER data.
* @return 0 on success.
* @return MEMORY_E when dynamic memory allocation fails.
* @return 0 on failure.
*/
int wolfSSL_PEM_write_bio(WOLFSSL_BIO* bio, const char *name,
const char *header, const unsigned char *data, long len)
Expand All @@ -15757,23 +15756,21 @@ int wolfSSL_PEM_write_bio(WOLFSSL_BIO* bio, const char *name,

/* Validate parameters. */
if ((bio == NULL) || (name == NULL) || (header == NULL) || (data == NULL)) {
err = 1;
err = BAD_FUNC_ARG;
}

/* Encode into a buffer. */
if ((!err) && (pem_write_data(name, header, data, len, &pem, &pemLen) !=
0)) {
pemLen = 0;
err = 1;
if (!err) {
err = pem_write_data(name, header, data, len, &pem, &pemLen);
}

/* Write PEM into BIO. */
if ((!err) && (wolfSSL_BIO_write(bio, pem, pemLen) != (int)pemLen)) {
pemLen = 0;
err = IO_FAILED_E;
}

XFREE(pem, NULL, DYNAMIC_TYPE_TMP_BUFFER);
return pemLen;
return (!err) ? pemLen : 0;
}
#endif /* !NO_BIO */

Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/src/cmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ int wc_CmacUpdate(Cmac* cmac, const byte* in, word32 inSz)
/* Clear CRYPTOCB_UNAVAILABLE return code */
ret = 0;

while (inSz != 0) {
while ((ret == 0) && (inSz != 0)) {
word32 add = min(inSz, AES_BLOCK_SIZE - cmac->bufferSz);
XMEMCPY(&cmac->buffer[cmac->bufferSz], in, add);

Expand Down

0 comments on commit 568fda0

Please sign in to comment.