summaryrefslogtreecommitdiff
path: root/openbsd-compat/fmt_scaled.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2017-03-29 16:32:57 +1100
committerDarren Tucker <dtucker@zip.com.au>2017-03-29 16:32:57 +1100
commitd427b73bf5a564f663d16546dbcbd84ba8b9d4af (patch)
treea099e07bdc5b3c87e8699e0502384b8314888ff2 /openbsd-compat/fmt_scaled.c
parentd13281f2964abc5f2e535e1613c77fc61b0c53e7 (diff)
Import fmt_scaled.c rev 1.14 from OpenBSD.
Catch integer underflow in scan_scaled reported by Nicolas Iooss. ok deraadt@ djm@
Diffstat (limited to 'openbsd-compat/fmt_scaled.c')
-rw-r--r--openbsd-compat/fmt_scaled.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/openbsd-compat/fmt_scaled.c b/openbsd-compat/fmt_scaled.c
index e5533b2d..7e6a57d4 100644
--- a/openbsd-compat/fmt_scaled.c
+++ b/openbsd-compat/fmt_scaled.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fmt_scaled.c,v 1.13 2017/03/11 23:37:23 djm Exp $ */
+/* $OpenBSD: fmt_scaled.c,v 1.14 2017/03/15 00:13:18 dtucker Exp $ */
/*
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
@@ -175,6 +175,11 @@ scan_scaled(char *scaled, long long *result)
return -1;
}
+ if (whole <= LLONG_MIN / scale_fact) {
+ errno = ERANGE;
+ return -1;
+ }
+
/* scale whole part */
whole *= scale_fact;