diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:33:32 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:33:32 +0000 |
commit | 8bb05ac73a5b448b339ce0bc8d396c82c459b47f (patch) | |
tree | 1fdda006866bca20d41cb206767ea5241e36852f /libfdisk/src/dos.c | |
parent | Adding debian version 2.39.3-11. (diff) | |
download | util-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.tar.xz util-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.zip |
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libfdisk/src/dos.c')
-rw-r--r-- | libfdisk/src/dos.c | 18 |
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; } |