From d5bab2c0e1f78734f91e9f6da2c72af550f4223f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 12 Nov 2013 16:14:33 +0100 Subject: [PATCH] * grub-core/loader/i386/bsd.c: Remove variable length arrays. --- ChangeLog | 4 ++++ grub-core/loader/i386/bsd.c | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 724457f0d..bd723d3f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-11-12 Vladimir Serbinenko + + * grub-core/loader/i386/bsd.c: Remove variable length arrays. + 2013-11-12 Vladimir Serbinenko * grub-core/efiemu/prepare.c: Remove variable length arrays. diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index 1e16ab71b..006632e56 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -1040,8 +1040,12 @@ grub_netbsd_add_boot_disk_and_wedge (void) grub_uint64_t raw[GRUB_DISK_SECTOR_SIZE / 8]; struct grub_partition_bsd_disk_label label; } buf; - grub_uint8_t *hash; - GRUB_PROPERLY_ALIGNED_ARRAY (ctx, GRUB_MD_MD5->contextsize); + + if (GRUB_MD_MD5->mdlen > GRUB_CRYPTO_MAX_MDLEN) + { + grub_error (GRUB_ERR_BUG, "mdlen too long"); + return; + } dev = grub_device_open (0); if (! (dev && dev->disk && dev->disk->partition)) @@ -1067,6 +1071,7 @@ grub_netbsd_add_boot_disk_and_wedge (void) /* Fill bootwedge. */ { struct grub_netbsd_btinfo_bootwedge biw; + grub_uint8_t hash[GRUB_CRYPTO_MAX_MDLEN]; grub_memset (&biw, 0, sizeof (biw)); biw.biosdev = biosdev; @@ -1075,10 +1080,8 @@ grub_netbsd_add_boot_disk_and_wedge (void) biw.matchblk = partmapsector; biw.matchnblks = 1; - GRUB_MD_MD5->init (&ctx); - GRUB_MD_MD5->write (&ctx, buf.raw, GRUB_DISK_SECTOR_SIZE); - GRUB_MD_MD5->final (&ctx); - hash = GRUB_MD_MD5->read (&ctx); + grub_crypto_hash (GRUB_MD_MD5, hash, + buf.raw, GRUB_DISK_SECTOR_SIZE); memcpy (biw.matchhash, hash, 16); grub_bsd_add_meta (NETBSD_BTINFO_BOOTWEDGE, &biw, sizeof (biw));