diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2015-11-15 01:22:40 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2015-11-15 01:22:40 +0000 |
commit | b8b7f40768251382a7ea30f00daa778c34969a20 (patch) | |
tree | a39f62a557ae16d7f5d67325fa0b427853f1367c /sbin/fdisk/fdisk.c | |
parent | 578abdf729f1f7f850bbbd035e9c27060e47a7e9 (diff) |
Move zapping of invalid GPT data into GPT_get_gpt() rather than
returning a value to tell callers to zap it. Use consistant idiom
to check for the presence of a GPT (check gh.gh_sig). When zapping
GPT, always zap both the header and partition table just for
paranoia's sake.
Diffstat (limited to 'sbin/fdisk/fdisk.c')
-rw-r--r-- | sbin/fdisk/fdisk.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index d4ee829df9f..68a9a9a075d 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdisk.c,v 1.88 2015/11/14 21:17:08 krw Exp $ */ +/* $OpenBSD: fdisk.c,v 1.89 2015/11/15 01:22:39 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -162,9 +162,9 @@ main(int argc, char *argv[]) DISK_open(); /* Get the GPT if present. */ - if (GPT_get_gpt()) { - memset(&gh, 0, sizeof(gh)); - memset(&gp, 0, sizeof(gp)); + GPT_get_gpt(); + + if (letoh64(gh.gh_sig) != GPTSIGNATURE) { if (DL_GETDSIZE(&dl) > disk.size) warnx("disk too large (%llu sectors). size truncated.", (unsigned long long)DL_GETDSIZE(&dl)); @@ -205,7 +205,8 @@ main(int argc, char *argv[]) close(fd); } if (f_flag || MBR_protective_mbr(&initial_mbr) != 0) { - memset(&gh, 0, sizeof(struct gpt_header)); + memset(&gh, 0, sizeof(gh)); + memset(&gp, 0, sizeof(gp)); MBR_parse(&dos_mbr, 0, 0, &initial_mbr); } |