[openssh-commits] [openssh] 03/03: Import fmt_scaled.c rev 1.16 from OpenBSD.

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Mar 29 16:35:53 AEDT 2017


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit 282cad2240c4fbc104c2f2df86d688192cbbe4bb
Author: Darren Tucker <dtucker at zip.com.au>
Date:   Wed Mar 29 16:34:44 2017 +1100

    Import fmt_scaled.c rev 1.16 from OpenBSD.
    
    Fix overly-conservative overflow checks on mulitplications and add checks
    on additions.  This allows scan_scaled to work up to +/-LLONG_MAX (LLONG_MIN
    will still be flagged as a range error).  ok millert@
---
 openbsd-compat/fmt_scaled.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/openbsd-compat/fmt_scaled.c b/openbsd-compat/fmt_scaled.c
index 8af8660..7c5193e 100644
--- a/openbsd-compat/fmt_scaled.c
+++ b/openbsd-compat/fmt_scaled.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: fmt_scaled.c,v 1.15 2017/03/15 05:25:56 dtucker Exp $	*/
+/*	$OpenBSD: fmt_scaled.c,v 1.16 2017/03/16 02:40:46 dtucker Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003 Ian F. Darwin.  All rights reserved.
@@ -125,22 +125,30 @@ scan_scaled(char *scaled, long long *result)
 				/* ignore extra fractional digits */
 				continue;
 			fract_digits++;		/* for later scaling */
-			if (fpart >= LLONG_MAX / 10) {
+			if (fpart > LLONG_MAX / 10) {
 				errno = ERANGE;
 				return -1;
 			}
 			fpart *= 10;
+			if (i > LLONG_MAX - fpart) {
+				errno = ERANGE;
+				return -1;
+			}
 			fpart += i;
 		} else {				/* normal digit */
 			if (++ndigits >= MAX_DIGITS) {
 				errno = ERANGE;
 				return -1;
 			}
-			if (whole >= LLONG_MAX / 10) {
+			if (whole > LLONG_MAX / 10) {
 				errno = ERANGE;
 				return -1;
 			}
 			whole *= 10;
+			if (i > LLONG_MAX - whole) {
+				errno = ERANGE;
+				return -1;
+			}
 			whole += i;
 		}
 	}

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list