From e0127364786d70f47c0b6272d233a4983675f704 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 15 Oct 2013 17:55:20 +0200 Subject: [PATCH] * grub-core/disk/geli.c (grub_util_get_geli_uuid): Close handle after read. --- ChangeLog | 5 +++++ grub-core/disk/geli.c | 12 +++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4122920dd..f71c5ef19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-10-15 Vladimir Serbinenko + + * grub-core/disk/geli.c (grub_util_get_geli_uuid): Close handle after + read. + 2013-10-15 Vladimir Serbinenko * grub-core/disk/cryptodisk.c: Use grub_util_fd_strerror instead diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index 3e029402a..c4864dc1b 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -198,19 +198,13 @@ make_uuid (const struct grub_geli_phdr *header, #ifdef GRUB_UTIL -#include -#include -#include -#include #include -#include -#include #include char * grub_util_get_geli_uuid (const char *dev) { - grub_util_fd_t fd = grub_util_fd_open (dev, GRUB_UTIL_FD_O_RDONLY); + grub_util_fd_t fd; grub_uint64_t s; unsigned log_secsize; grub_uint8_t hdr[512]; @@ -218,6 +212,8 @@ grub_util_get_geli_uuid (const char *dev) char *uuid; gcry_err_code_t err; + fd = grub_util_fd_open (dev, GRUB_UTIL_FD_O_RDONLY); + if (!GRUB_UTIL_FD_IS_VALID (fd)) return NULL; @@ -228,6 +224,8 @@ grub_util_get_geli_uuid (const char *dev) uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1); if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0) grub_util_error ("%s", _("couldn't read ELI metadata")); + + grub_util_fd_close (fd); COMPILE_TIME_ASSERT (sizeof (header) <= 512); header = (void *) &hdr;