Fix typos and potential leaks in ECC as well
parent
3444d6678a
commit
78a0dcb687
|
@ -193,7 +193,7 @@ int wolfCLU_genKey_ECC(RNG* rng, char* fName, int directive, int fmt,
|
|||
* Output key(s) to file(s)
|
||||
*/
|
||||
|
||||
/* set up the file name outut beffer */
|
||||
/* set up the file name output buffer */
|
||||
fOutNameBuf = (char*)XMALLOC(fNameSz + fExtSz, HEAP_HINT,
|
||||
DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (fOutNameBuf == NULL)
|
||||
|
@ -217,18 +217,21 @@ int wolfCLU_genKey_ECC(RNG* rng, char* fName, int directive, int fmt,
|
|||
|
||||
derBufSz = wc_EccPrivateKeyToDer(&key, derBuf, maxDerBufSz);
|
||||
if (derBufSz < 0) {
|
||||
XFREE(fOutNameBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(derBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return derBufSz;
|
||||
}
|
||||
|
||||
file = fopen(fOutNameBuf, "wb");
|
||||
if (file == XBADFILE) {
|
||||
XFREE(fOutNameBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(derBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return OUTPUT_FILE_ERROR;
|
||||
}
|
||||
|
||||
ret = (int)fwrite(derBuf, 1, derBufSz, file);
|
||||
if (ret <= 0) {
|
||||
XFREE(fOutNameBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(derBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
fclose(file);
|
||||
return OUTPUT_FILE_ERROR;
|
||||
|
@ -245,6 +248,7 @@ int wolfCLU_genKey_ECC(RNG* rng, char* fName, int directive, int fmt,
|
|||
|
||||
derBufSz = wc_EccPublicKeyToDer(&key, derBuf, maxDerBufSz, 1);
|
||||
if (derBufSz < 0) {
|
||||
XFREE(fOutNameBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(derBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return derBufSz;
|
||||
}
|
||||
|
@ -252,6 +256,7 @@ int wolfCLU_genKey_ECC(RNG* rng, char* fName, int directive, int fmt,
|
|||
file = fopen(fOutNameBuf, "wb");
|
||||
if (file == XBADFILE) {
|
||||
XFREE(fOutNameBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(derBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return OUTPUT_FILE_ERROR;
|
||||
}
|
||||
|
||||
|
@ -259,6 +264,7 @@ int wolfCLU_genKey_ECC(RNG* rng, char* fName, int directive, int fmt,
|
|||
if (ret <= 0) {
|
||||
fclose(file);
|
||||
XFREE(fOutNameBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(derBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return OUTPUT_FILE_ERROR;
|
||||
}
|
||||
fclose(file);
|
||||
|
@ -266,6 +272,7 @@ int wolfCLU_genKey_ECC(RNG* rng, char* fName, int directive, int fmt,
|
|||
default:
|
||||
printf("Invalid directive\n");
|
||||
XFREE(fOutNameBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(derBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
|
@ -333,7 +340,7 @@ int wolfCLU_genKey_RSA(RNG* rng, char* fName, int directive, int fmt, int
|
|||
* Output key(s) to file(s)
|
||||
*/
|
||||
|
||||
/* set up the file name outut beffer */
|
||||
/* set up the file name output buffer */
|
||||
fOutNameBuf = (char*)XMALLOC(fNameSz + fExtSz, HEAP_HINT,
|
||||
DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (fOutNameBuf == NULL)
|
||||
|
|
Loading…
Reference in New Issue