Fix overflow checking.

There are some other potential problems related to overflowing racct
counters; I'll revisit those later.

Submitted by:	Pieter de Goeje (earlier version)
Reviewed by:	emaste@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Edward Tomasz Napierala 2016-04-12 18:13:24 +00:00
parent b3b4ccc70a
commit f459a81824

View File

@ -495,17 +495,11 @@ xadd(uint64_t a, uint64_t b)
static uint64_t static uint64_t
xmul(uint64_t a, uint64_t b) xmul(uint64_t a, uint64_t b)
{ {
uint64_t c;
if (a == 0 || b == 0) if (b != 0 && a > UINT64_MAX / b)
return (0);
c = a * b;
if (c < a || c < b)
return (UINT64_MAX); return (UINT64_MAX);
return (c); return (a * b);
} }
/* /*