diff options
author | Toomas Soome <tsoome@me.com> | 2020-03-19 19:30:24 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2020-03-22 19:41:56 +0200 |
commit | 3fd7ddd197d247df98d4c6efd8fb2a6447e338de (patch) | |
tree | 405e4bccc790894767b84f093dd8be4cdce6dcc2 /usr/src | |
parent | 27183ddc1219d1250969ffa63c48ed8281cb4eb0 (diff) | |
download | illumos-joyent-3fd7ddd197d247df98d4c6efd8fb2a6447e338de.tar.gz |
12400 loader: misaligned access of dos_partition structure
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Approved by: Robert Mustacchi <rm@fingolfin.org>
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/boot/Makefile.version | 2 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/common/part.c | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version index 600cec3537..164e3416ec 100644 --- a/usr/src/boot/Makefile.version +++ b/usr/src/boot/Makefile.version @@ -33,4 +33,4 @@ LOADER_VERSION = 1.1 # Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes. # The version is processed from left to right, the version number can only # be increased. -BOOT_VERSION = $(LOADER_VERSION)-2020.02.26.1 +BOOT_VERSION = $(LOADER_VERSION)-2020.03.19.1 diff --git a/usr/src/boot/sys/boot/common/part.c b/usr/src/boot/sys/boot/common/part.c index c2573d1d84..bcc792dcd4 100644 --- a/usr/src/boot/sys/boot/common/part.c +++ b/usr/src/boot/sys/boot/common/part.c @@ -769,6 +769,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread) int has_ext; #endif table = NULL; + dp = NULL; buf = malloc(sectorsize); if (buf == NULL) return (NULL); @@ -829,7 +830,11 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread) goto out; } /* Check that we have PMBR. Also do some validation. */ - dp = (struct dos_partition *)(buf + DOSPARTOFF); + dp = malloc(NDOSPART * sizeof (struct dos_partition)); + if (dp == NULL) + goto out; + bcopy(buf + DOSPARTOFF, dp, NDOSPART * sizeof (struct dos_partition)); + /* * macOS can create PMBR partition in a hybrid MBR; that is, an MBR * partition which has a DOSTYP_PMBR entry defined to start at sector 1. @@ -891,6 +896,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread) #endif /* LOADER_MBR_SUPPORT */ #endif /* LOADER_MBR_SUPPORT || LOADER_GPT_SUPPORT */ out: + free(dp); free(buf); return (table); } |