summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2022-04-13 22:29:31 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2022-04-13 22:29:31 +0000
commitc484573384ad29947e061f7ab050e5f54e9a7983 (patch)
tree3f51340a970eaf95198d2a9021652f5ab9a3e6df /sbin
parent480567900e2192f78a854120d76d9d1b954c3cde (diff)
Correct a gh_part_csum calculation used in debug output.
Always calculate the GPT partition entries checksum over gh_part_num * gh_part_size bytes, not the maximal size of the internal partition entries array. No functional change.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fdisk/gpt.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sbin/fdisk/gpt.c b/sbin/fdisk/gpt.c
index 8e8d9834b13..9d06444bcc6 100644
--- a/sbin/fdisk/gpt.c
+++ b/sbin/fdisk/gpt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gpt.c,v 1.63 2022/04/13 15:32:33 krw Exp $ */
+/* $OpenBSD: gpt.c,v 1.64 2022/04/13 22:29:30 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
@@ -433,7 +433,7 @@ add_partition(const uint8_t *beuuid, const char *name, uint64_t sectors)
{
struct uuid uuid, gp_type;
int rslt;
- uint64_t end, freesectors, start;
+ uint64_t end, freesectors, gpbytes, start;
uint32_t status, pn, pncnt;
uuid_dec_be(beuuid, &uuid);
@@ -477,7 +477,8 @@ add_partition(const uint8_t *beuuid, const char *name, uint64_t sectors)
goto done;
uuid_enc_le(&gp[pn].gp_guid, &uuid);
- gh.gh_part_csum = htole32(crc32((unsigned char *)&gp, sizeof(gp)));
+ gpbytes = letoh32(gh.gh_part_num) * letoh32(gh.gh_part_size);
+ gh.gh_part_csum = htole32(crc32((unsigned char *)&gp, gpbytes));
gh.gh_csum = 0;
gh.gh_csum = htole32(crc32((unsigned char *)&gh, letoh32(gh.gh_size)));