From e1ed0ab45c96c94e0f00971ee3d6b23d071abd4d Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Thu, 29 Jan 2015 20:07:58 -0800 Subject: lib21: Close the open file when finished using it BUG=none BRANCH=ToT TEST=make runtests Change-Id: Ie4ac1ae71e70b62f9bc89fa1441ff5ca65199f79 Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/244673 Reviewed-by: Randall Spangler --- host/lib21/host_key.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'host/lib21') 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; -- cgit v1.2.1