summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2011-12-01 16:44:30 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2011-12-01 16:44:30 +0000
commitc7c7266967ad856e3d82a824a203e97882280591 (patch)
treecce57fec6ae47d2e943073d01607243bf24b3d3f /sbin
parent3d6a23dfa0366e3927fc57b09de5dd01f5a42b36 (diff)
Fix negating of unsigned d_secsize. FIRST, cast to signed type,
THEN negate. Fixes issues with 'b' and 'k' size suffixes. Make error message more clear while here. Found, and fix provided, by David Imhoff via bugs@. Thanks!
Diffstat (limited to 'sbin')
-rw-r--r--sbin/disklabel/editor.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 8c2bfda0d18..45cca0de09e 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.259 2011/10/06 21:16:01 deraadt Exp $ */
+/* $OpenBSD: editor.c,v 1.260 2011/12/01 16:44:29 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -1178,12 +1178,13 @@ getuint(struct disklabel *lp, char *prompt, char *helpstring,
buf[--n] = '\0';
break;
case 'b':
- mult = -lp->d_secsize;
+ mult = -(int64_t)lp->d_secsize;
buf[--n] = '\0';
break;
case 'k':
if (lp->d_secsize > 1024)
- mult = -lp->d_secsize / 1024LL;
+ mult = -(int64_t)lp->d_secsize /
+ 1024LL;
else
mult = 1024LL / lp->d_secsize;
buf[--n] = '\0';
@@ -1948,7 +1949,7 @@ get_size(struct disklabel *lp, int partno)
else if (ui == ULLONG_MAX)
fputs("Invalid entry\n", stderr);
else if (ui == 0)
- fputs("The size must be > 0\n", stderr);
+ fputs("The size must be > 0 sectors\n", stderr);
else if (ui + DL_GETPOFFSET(pp) > ending_sector)
fprintf(stderr, "The size can't be more than "
"%llu sectors, or the partition would\n"