mirror of https://gitee.com/openkylin/sysstat.git
update common.c.
Signed-off-by: hehedaddd <1780243524@qq.com>
This commit is contained in:
parent
124db06be9
commit
74ae05575f
12
common.c
12
common.c
|
@ -447,12 +447,14 @@ int check_dir(char *dirname)
|
||||||
void check_overflow(unsigned int val1, unsigned int val2,
|
void check_overflow(unsigned int val1, unsigned int val2,
|
||||||
unsigned int val3)
|
unsigned int val3)
|
||||||
{
|
{
|
||||||
if ((unsigned long long) val1 * (unsigned long long) val2 *
|
if ((val1 != 0) && (val2 != 0) && (val3 != 0) &&
|
||||||
(unsigned long long) val3 > UINT_MAX) {
|
(((unsigned long long) UINT_MAX / (unsigned long long) val1 <
|
||||||
|
(unsigned long long) val2) ||
|
||||||
|
((unsigned long long) UINT_MAX / ((unsigned long long) val1 * (unsigned long long) val2) <
|
||||||
|
(unsigned long long) val3))) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "%s: Overflow detected (%llu). Aborting...\n",
|
fprintf(stderr, "%s: Overflow detected (%u,%u,%u). Aborting...\n",
|
||||||
__FUNCTION__, (unsigned long long) val1 * (unsigned long long) val2 *
|
__FUNCTION__, val1, val2, val3);
|
||||||
(unsigned long long) val3);
|
|
||||||
#endif
|
#endif
|
||||||
exit(4);
|
exit(4);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue