mirror of
git://anongit.mindrot.org/openssh.git
synced 2025-02-18 06:46:55 +00:00
Import fmt_scaled.c rev 1.15 from OpenBSD.
Collapse underflow and overflow checks into a single block. ok djm@ millert@
This commit is contained in:
parent
d427b73bf5
commit
c73a229e4e
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: fmt_scaled.c,v 1.14 2017/03/15 00:13:18 dtucker Exp $ */
|
/* $OpenBSD: fmt_scaled.c,v 1.15 2017/03/15 05:25:56 dtucker Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
|
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
|
||||||
@ -170,12 +170,9 @@ scan_scaled(char *scaled, long long *result)
|
|||||||
}
|
}
|
||||||
scale_fact = scale_factors[i];
|
scale_fact = scale_factors[i];
|
||||||
|
|
||||||
if (whole >= LLONG_MAX / scale_fact) {
|
/* check for overflow and underflow after scaling */
|
||||||
errno = ERANGE;
|
if (whole > LLONG_MAX / scale_fact ||
|
||||||
return -1;
|
whole < LLONG_MIN / scale_fact) {
|
||||||
}
|
|
||||||
|
|
||||||
if (whole <= LLONG_MIN / scale_fact) {
|
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user