diff options
author | Bill Richardson <wfrichar@chromium.org> | 2015-01-29 20:07:58 -0800 |
---|---|---|
committer | Bill Richardson <wfrichar@chromium.org> | 2015-01-31 00:41:09 +0000 |
commit | e1ed0ab45c96c94e0f00971ee3d6b23d071abd4d (patch) | |
tree | 09edb6dc2c7abcfa5f074492134be95a35a0d197 | |
parent | 06eb78c0f64c898c8d564b3efbffe349a8ae79b2 (diff) | |
download | vboot_reference-e1ed0ab45c96c94e0f00971ee3d6b23d071abd4d.tar.gz |
lib21: Close the open file when finished using it
BUG=none
BRANCH=ToT
TEST=make runtests
Change-Id: Ie4ac1ae71e70b62f9bc89fa1441ff5ca65199f79
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/244673
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | host/lib21/host_key.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/host/lib21/host_key.c b/host/lib21/host_key.c index 1f456835..5123b85d 100644 --- a/host/lib21/host_key.c +++ b/host/lib21/host_key.c @@ -144,13 +144,15 @@ int vb2_private_key_read_pem(struct vb2_private_key **key_ptr, return VB2_ERROR_READ_PEM_ALLOC; /* Read private key */ - f = fopen(filename, "r"); + f = fopen(filename, "rb"); if (!f) { free(key); return VB2_ERROR_READ_PEM_FILE_OPEN; } key->rsa_private_key = PEM_read_RSAPrivateKey(f, NULL, NULL, NULL); + fclose(f); + if (!key->rsa_private_key) { free(key); return VB2_ERROR_READ_PEM_RSA; |