summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2016-04-12 18:13:24 +0000
committertrasz <trasz@FreeBSD.org>2016-04-12 18:13:24 +0000
commit611644daf2cc6d8dd85237406c15e73876658754 (patch)
treed4e8e77738ce22c954ab3396e8158351a54e6458
parent1f54f511a0befc71ec0b2054941e04d32c8806a2 (diff)
downloadFreeBSD-src-611644daf2cc6d8dd85237406c15e73876658754.zip
FreeBSD-src-611644daf2cc6d8dd85237406c15e73876658754.tar.gz
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
-rw-r--r--sys/kern/kern_rctl.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/sys/kern/kern_rctl.c b/sys/kern/kern_rctl.c
index 2442852..98b5055 100644
--- a/sys/kern/kern_rctl.c
+++ b/sys/kern/kern_rctl.c
@@ -495,17 +495,11 @@ xadd(uint64_t a, uint64_t b)
static uint64_t
xmul(uint64_t a, uint64_t b)
{
- uint64_t c;
-
- if (a == 0 || b == 0)
- return (0);
- c = a * b;
-
- if (c < a || c < b)
+ if (b != 0 && a > UINT64_MAX / b)
return (UINT64_MAX);
- return (c);
+ return (a * b);
}
/*
OpenPOWER on IntegriCloud