summaryrefslogtreecommitdiff
path: root/sbin/fdisk/cmd.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2017-11-13 21:00:33 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2017-11-13 21:00:33 +0000
commit86762cb208566602bafc2f196bfbda2925f77bce (patch)
tree83bf1b300e863b5f7822d5bdebdb08eb4b4cef9e /sbin/fdisk/cmd.c
parent108a3cf8b5ed8272457c49260098d4673e585300 (diff)
Constrain MBR partition offsets to 0 .. disk.size - 1.
Issue reported by Alexi Malinin via bugs@. Thanks!
Diffstat (limited to 'sbin/fdisk/cmd.c')
-rw-r--r--sbin/fdisk/cmd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index 37acb4dad1b..c467056e0b8 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.97 2016/09/03 17:46:19 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.98 2017/11/13 21:00:32 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -268,7 +268,7 @@ Xedit(char *args, struct mbr *mbr)
/* Fix up CHS values for LBA */
PRT_fix_CHS(pp);
} else {
- pp->bs = getuint64("Partition offset", pp->bs, 0, disk.size);
+ pp->bs = getuint64("Partition offset", pp->bs, 0, disk.size - 1);
pp->ns = getuint64("Partition size", pp->ns, 1,
disk.size - pp->bs);