|
@ -1,4 +1,4 @@ |
|
|
/* $OpenBSD: fmt_scaled.c,v 1.12 2013/11/29 19:00:51 deraadt Exp $ */ |
|
|
|
|
|
|
|
|
/* $OpenBSD: fmt_scaled.c,v 1.13 2017/03/11 23:37:23 djm Exp $ */ |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved. |
|
|
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved. |
|
@ -121,6 +121,10 @@ scan_scaled(char *scaled, long long *result) |
|
|
/* ignore extra fractional digits */ |
|
|
/* ignore extra fractional digits */ |
|
|
continue; |
|
|
continue; |
|
|
fract_digits++; /* for later scaling */ |
|
|
fract_digits++; /* for later scaling */ |
|
|
|
|
|
if (fpart >= LLONG_MAX / 10) { |
|
|
|
|
|
errno = ERANGE; |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
fpart *= 10; |
|
|
fpart *= 10; |
|
|
fpart += i; |
|
|
fpart += i; |
|
|
} else { /* normal digit */ |
|
|
} else { /* normal digit */ |
|
@ -128,6 +132,10 @@ scan_scaled(char *scaled, long long *result) |
|
|
errno = ERANGE; |
|
|
errno = ERANGE; |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
if (whole >= LLONG_MAX / 10) { |
|
|
|
|
|
errno = ERANGE; |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
whole *= 10; |
|
|
whole *= 10; |
|
|
whole += i; |
|
|
whole += i; |
|
|
} |
|
|
} |
|
@ -158,6 +166,11 @@ scan_scaled(char *scaled, long long *result) |
|
|
} |
|
|
} |
|
|
scale_fact = scale_factors[i]; |
|
|
scale_fact = scale_factors[i]; |
|
|
|
|
|
|
|
|
|
|
|
if (whole >= LLONG_MAX / scale_fact) { |
|
|
|
|
|
errno = ERANGE; |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/* scale whole part */ |
|
|
/* scale whole part */ |
|
|
whole *= scale_fact; |
|
|
whole *= scale_fact; |
|
|
|
|
|
|
|
|