diff options
author | Greg Zaverucha <gregz@microsoft.com> | 2017-06-27 17:38:25 -0700 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2017-06-29 00:38:26 +0200 |
commit | 519a5d1ef2ca3ba0adf0bc1d7dff984e8523d813 (patch) | |
tree | 6819afead52f8f20ecb870f09f46ac169f881d07 /doc/man3 | |
parent | afe9bba749b9fd897b7e7d416d904852d867d2c2 (diff) | |
download | openssl-519a5d1ef2ca3ba0adf0bc1d7dff984e8523d813.tar.gz |
Fix sample code
Fix memory leak in sample encryption code and check return value of
fopen.
CLA: trivial
Signed-off-by: Greg Zaverucha <gregz@microsoft.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3790)
Diffstat (limited to 'doc/man3')
-rw-r--r-- | doc/man3/EVP_EncryptInit.pod | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/doc/man3/EVP_EncryptInit.pod b/doc/man3/EVP_EncryptInit.pod index 46e6a57d4b..66e1ffb688 100644 --- a/doc/man3/EVP_EncryptInit.pod +++ b/doc/man3/EVP_EncryptInit.pod @@ -552,6 +552,7 @@ Encrypt a string using IDEA: if (!EVP_EncryptUpdate(ctx, outbuf, &outlen, intext, strlen(intext))) { /* Error */ + EVP_CIPHER_CTX_free(ctx); return 0; } /* @@ -560,6 +561,7 @@ Encrypt a string using IDEA: */ if (!EVP_EncryptFinal_ex(ctx, outbuf + outlen, &tmplen)) { /* Error */ + EVP_CIPHER_CTX_free(ctx); return 0; } outlen += tmplen; @@ -571,6 +573,10 @@ Encrypt a string using IDEA: * NULs. */ out = fopen(outfile, "wb"); + if (out == NULL) { + /* Error */ + return 0; + } fwrite(outbuf, 1, outlen, out); fclose(out); return 1; |