* grub-core/disk/geli.c (grub_util_get_geli_uuid): Close handle after

read.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-10-15 17:55:20 +02:00
parent 20d535419f
commit e012736478
2 changed files with 10 additions and 7 deletions

View file

@ -1,3 +1,8 @@
2013-10-15 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/geli.c (grub_util_get_geli_uuid): Close handle after
read.
2013-10-15 Vladimir Serbinenko <phcoder@gmail.com> 2013-10-15 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/cryptodisk.c: Use grub_util_fd_strerror instead * grub-core/disk/cryptodisk.c: Use grub_util_fd_strerror instead

View file

@ -198,19 +198,13 @@ make_uuid (const struct grub_geli_phdr *header,
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <grub/emu/hostdisk.h> #include <grub/emu/hostdisk.h>
#include <unistd.h>
#include <string.h>
#include <grub/emu/misc.h> #include <grub/emu/misc.h>
char * char *
grub_util_get_geli_uuid (const char *dev) 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; grub_uint64_t s;
unsigned log_secsize; unsigned log_secsize;
grub_uint8_t hdr[512]; grub_uint8_t hdr[512];
@ -218,6 +212,8 @@ grub_util_get_geli_uuid (const char *dev)
char *uuid; char *uuid;
gcry_err_code_t err; gcry_err_code_t err;
fd = grub_util_fd_open (dev, GRUB_UTIL_FD_O_RDONLY);
if (!GRUB_UTIL_FD_IS_VALID (fd)) if (!GRUB_UTIL_FD_IS_VALID (fd))
return NULL; return NULL;
@ -228,6 +224,8 @@ grub_util_get_geli_uuid (const char *dev)
uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1); uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1);
if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0) if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0)
grub_util_error ("%s", _("couldn't read ELI metadata")); grub_util_error ("%s", _("couldn't read ELI metadata"));
grub_util_fd_close (fd);
COMPILE_TIME_ASSERT (sizeof (header) <= 512); COMPILE_TIME_ASSERT (sizeof (header) <= 512);
header = (void *) &hdr; header = (void *) &hdr;