Import fmt_scaled.c rev 1.14 from OpenBSD.

Catch integer underflow in scan_scaled reported by Nicolas Iooss.
ok deraadt@ djm@
This commit is contained in:
Darren Tucker 2017-03-29 16:32:57 +11:00
parent d13281f296
commit d427b73bf5
1 changed files with 6 additions and 1 deletions

View File

@ -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. * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
@ -175,6 +175,11 @@ scan_scaled(char *scaled, long long *result)
return -1; return -1;
} }
if (whole <= LLONG_MIN / scale_fact) {
errno = ERANGE;
return -1;
}
/* scale whole part */ /* scale whole part */
whole *= scale_fact; whole *= scale_fact;