summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/dos.c
diff options
context:
space:
mode:
Diffstat (limited to 'libfdisk/src/dos.c')
-rw-r--r--libfdisk/src/dos.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index 7970ae1..ecf0b36 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -67,7 +67,7 @@ struct fdisk_dos_label {
/*
* Partition types
*/
-static struct fdisk_parttype dos_parttypes[] = {
+static const struct fdisk_parttype dos_parttypes[] = {
#include "pt-mbr-partnames.h"
};
@@ -792,7 +792,7 @@ static void get_partition_table_geometry(struct fdisk_context *cxt,
unsigned char *bufp = cxt->firstsector;
struct { unsigned int c, h, o, v; } t[8];
unsigned int n1, n2, n3, n4, n5, n6;
- struct dos_partition *p;
+ const struct dos_partition *p;
unsigned int c, h, s, l;
unsigned int hh, ss;
unsigned int sects;
@@ -1727,14 +1727,22 @@ static int dos_verify_disklabel(struct fdisk_context *cxt)
{
size_t i, j;
fdisk_sector_t total = 1, n_sectors = cxt->total_sectors;
- fdisk_sector_t first[cxt->label->nparts_max],
- last[cxt->label->nparts_max];
+ fdisk_sector_t *first, *last;
struct dos_partition *p;
struct fdisk_dos_label *l = self_label(cxt);
int nerrors = 0;
assert(fdisk_is_label(cxt, DOS));
+ first = calloc(cxt->label->nparts_max, sizeof(*first));
+ last = calloc(cxt->label->nparts_max, sizeof(*first));
+
+ if (!first || !last) {
+ free(first);
+ free(last);
+ return -ENOMEM;
+ }
+
fill_bounds(cxt, first, last);
for (i = 0; i < cxt->label->nparts_max; i++) {
struct pte *pe = self_pte(cxt, i);
@@ -1818,6 +1826,8 @@ static int dos_verify_disklabel(struct fdisk_context *cxt)
P_("%d error detected.", "%d errors detected.", nerrors),
nerrors);
+ free(first);
+ free(last);
return nerrors;
}