diff options
author | Tobias Weingartner <weingart@cvs.openbsd.org> | 2009-04-07 16:06:38 +0000 |
---|---|---|
committer | Tobias Weingartner <weingart@cvs.openbsd.org> | 2009-04-07 16:06:38 +0000 |
commit | 25b4f988f32e1078e0e1b91d955f72c093c76b6f (patch) | |
tree | e6f87ba80994677773e14d7f6a6589b940750f3a | |
parent | 4414bfbcccd0f412374a68c641a98627511adfb9 (diff) |
Fix the default value to be between low/high range. Thanks for
frantisek holop pointing out the issue. ok deraadt@
-rw-r--r-- | sbin/fdisk/misc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sbin/fdisk/misc.c b/sbin/fdisk/misc.c index ad20c5dafee..ae0ecaa2bc3 100644 --- a/sbin/fdisk/misc.c +++ b/sbin/fdisk/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.20 2008/12/01 20:15:35 ray Exp $ */ +/* $OpenBSD: misc.c,v 1.21 2009/04/07 16:06:37 weingart Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -98,7 +98,12 @@ ask_num(const char *str, int flags, int dflt, int low, int high, do { again: - num = dflt; + if (dflt < low) + num = low; + else if (dflt > high) + num = high; + else + num = dflt; if (flags == ASK_HEX) printf("%s [%X - %X]: [%X] ", str, low, high, num); else |