diff options
| author | Toomas Soome <tsoome@FreeBSD.org> | 2020-03-19 17:27:08 +0000 |
|---|---|---|
| committer | Toomas Soome <tsoome@FreeBSD.org> | 2020-03-19 17:27:08 +0000 |
| commit | 87d8d5ea3dd0a8ad2c0468660805017d6d45d937 (patch) | |
| tree | c275adaa25fe736770bee64c3f7d359b1e24e58e /stand | |
| parent | e4ee6c5444b0319aa3b73aa8215e9cfd44e4ee2c (diff) | |
Notes
Diffstat (limited to 'stand')
| -rw-r--r-- | stand/common/part.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/stand/common/part.c b/stand/common/part.c index e61d7ef90c3f..187da5d0179d 100644 --- a/stand/common/part.c +++ b/stand/common/part.c @@ -654,6 +654,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, int has_ext; #endif table = NULL; + dp = NULL; buf = malloc(sectorsize); if (buf == NULL) return (NULL); @@ -708,7 +709,11 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, 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)); + /* * In mac we can have PMBR partition in hybrid MBR; * that is, MBR partition which has DOSPTYP_PMBR entry defined as @@ -770,6 +775,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, #endif /* LOADER_MBR_SUPPORT */ #endif /* LOADER_MBR_SUPPORT || LOADER_GPT_SUPPORT */ out: + free(dp); free(buf); return (table); } |
