aboutsummaryrefslogtreecommitdiffstats
path: root/sbin/geom
diff options
context:
space:
mode:
authorAndrey V. Elsukov <ae@FreeBSD.org>2010-06-21 12:50:54 +0000
committerAndrey V. Elsukov <ae@FreeBSD.org>2010-06-21 12:50:54 +0000
commit02fc66090b69b6be00744fe818e943eeef6284e0 (patch)
treef42eece5392e92dc58c3f6163f638251d9d10d65 /sbin/geom
parent60ae52f785331b48d1f4e82a9cf3f2d0da9540d5 (diff)
downloadsrc-02fc66090b69b6be00744fe818e943eeef6284e0.tar.gz
src-02fc66090b69b6be00744fe818e943eeef6284e0.zip
Check for overflow before it occurs. Also add check for
negative numbers. Suggested by: ache Approved by: kib (mentor)
Notes
Notes: svn path=/head/; revision=209392
Diffstat (limited to 'sbin/geom')
-rw-r--r--sbin/geom/misc/subr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sbin/geom/misc/subr.c b/sbin/geom/misc/subr.c
index 7a4786fc87f2..5c6afe649265 100644
--- a/sbin/geom/misc/subr.c
+++ b/sbin/geom/misc/subr.c
@@ -139,7 +139,7 @@ g_parse_lba(const char *lbastr, unsigned sectorsize, off_t *sectors)
assert(sectors != NULL);
number = (off_t)strtoimax(lbastr, &s, 0);
- if (s == lbastr)
+ if (s == lbastr || number < 0)
return (EINVAL);
mult = 1;
@@ -187,7 +187,7 @@ sfx:
if (*s != '\0')
return (EINVAL);
done:
- if (mult * unit < mult || number * mult * unit < number)
+ if ((OFF_MAX / unit) < mult || (OFF_MAX / mult / unit) < number)
return (ERANGE);
number *= mult * unit;
if (number % sectorsize)