summaryrefslogtreecommitdiff
path: root/openbsd-compat/fmt_scaled.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/fmt_scaled.c')
-rw-r--r--openbsd-compat/fmt_scaled.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/openbsd-compat/fmt_scaled.c b/openbsd-compat/fmt_scaled.c
index 7e6a57d45..8af866016 100644
--- a/openbsd-compat/fmt_scaled.c
+++ b/openbsd-compat/fmt_scaled.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: fmt_scaled.c,v 1.14 2017/03/15 00:13:18 dtucker Exp $ */ 1/* $OpenBSD: fmt_scaled.c,v 1.15 2017/03/15 05:25:56 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved. 4 * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
@@ -170,12 +170,9 @@ scan_scaled(char *scaled, long long *result)
170 } 170 }
171 scale_fact = scale_factors[i]; 171 scale_fact = scale_factors[i];
172 172
173 if (whole >= LLONG_MAX / scale_fact) { 173 /* check for overflow and underflow after scaling */
174 errno = ERANGE; 174 if (whole > LLONG_MAX / scale_fact ||
175 return -1; 175 whole < LLONG_MIN / scale_fact) {
176 }
177
178 if (whole <= LLONG_MIN / scale_fact) {
179 errno = ERANGE; 176 errno = ERANGE;
180 return -1; 177 return -1;
181 } 178 }