summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2021-05-15 15:59:16 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2021-05-15 15:59:16 +0000
commitb33befb035925ce5b438f76024bb0f61447b0302 (patch)
treec25c29e93ab54e895d53b2c3a3a87eb190f1122f /sbin
parentf0f68d85e9094ba5a27503e40e7c018629e5349a (diff)
Add missing MBR_protective_mbr() check when writing edited GPT.
No intentional functional change.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fdisk/cmd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index 8ba7f5e6fd3..0c90654cd0c 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.103 2021/05/14 15:31:01 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.104 2021/05/15 15:59:15 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -410,7 +410,7 @@ int
Xwrite(char *args, struct mbr *mbr)
{
struct dos_mbr dos_mbr;
- int i, n;
+ int efi, i, n;
for (i = 0, n = 0; i < NDOSPART; i++)
if (mbr->part[i].id == 0xA6)
@@ -431,7 +431,8 @@ Xwrite(char *args, struct mbr *mbr)
if (letoh64(gh.gh_sig) == GPTSIGNATURE) {
printf("Writing GPT.\n");
- if (GPT_write() == -1) {
+ efi = MBR_protective_mbr(mbr);
+ if (efi == -1 || GPT_write() == -1) {
warn("error writing GPT");
return (CMD_CONT);
}