From: krw Date: Thu, 12 May 2022 11:04:27 +0000 (+0000) Subject: Prevent '-u' when operating on GPT formatted disks, as the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d7e4e1b3e68f6a250474eacb622f384a3b6140d2;p=openbsd Prevent '-u' when operating on GPT formatted disks, as the equivalent 'update' editing command already is. Avoids the destruction of the GPT when the preventative MBR is overwritten with the default MBR. ok deraadt@ --- diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index c9b58c78c53..2dd0704c238 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdisk.c,v 1.144 2022/04/24 12:13:37 krw Exp $ */ +/* $OpenBSD: fdisk.c,v 1.145 2022/05/12 11:04:27 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -187,6 +187,8 @@ main(int argc, char *argv[]) Xwrite(NULL, &mbr); break; case INIT_MBRBOOTCODE: + if (GPT_read(ANYGPT) == 0) + errx(1, "-u not available for GPT"); if (MBR_read(0, 0, &mbr)) errx(1, "Can't read MBR!"); memcpy(mbr.mbr_code, default_dmbr.dmbr_boot,