From 16c2114a7b1d34bdaa24c4eca7bd5e81f75736c0 Mon Sep 17 00:00:00 2001 From: krw Date: Wed, 13 Apr 2022 15:32:33 +0000 Subject: [PATCH] Correct a gh_csum calculation used in debug output. Always calculate the GPT header checksum over gh_size bytes (a.k.a. 92), not sizeof(struct gpt_header). Compilers in their wisdom may pad the struct to a nice round size, e.g. 96 bytes. No functional change. --- sbin/fdisk/gpt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/fdisk/gpt.c b/sbin/fdisk/gpt.c index 960b047a48c..8e8d9834b13 100644 --- a/sbin/fdisk/gpt.c +++ b/sbin/fdisk/gpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gpt.c,v 1.62 2022/04/13 15:07:25 krw Exp $ */ +/* $OpenBSD: gpt.c,v 1.63 2022/04/13 15:32:33 krw Exp $ */ /* * Copyright (c) 2015 Markus Muller * Copyright (c) 2015 Kenneth R Westerback @@ -479,7 +479,7 @@ add_partition(const uint8_t *beuuid, const char *name, uint64_t sectors) uuid_enc_le(&gp[pn].gp_guid, &uuid); gh.gh_part_csum = htole32(crc32((unsigned char *)&gp, sizeof(gp))); gh.gh_csum = 0; - gh.gh_csum = htole32(crc32((unsigned char *)&gh, sizeof(gh))); + gh.gh_csum = htole32(crc32((unsigned char *)&gh, letoh32(gh.gh_size))); return 0; -- 2.20.1