svn commit: r297864 - head/sys/kern

Edward Tomasz Napierala trasz at FreeBSD.org
Tue Apr 12 18:13:26 UTC 2016


Author: trasz
Date: Tue Apr 12 18:13:24 2016
New Revision: 297864
URL: https://svnweb.freebsd.org/changeset/base/297864

Log:
  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

Modified:
  head/sys/kern/kern_rctl.c

Modified: head/sys/kern/kern_rctl.c
==============================================================================
--- head/sys/kern/kern_rctl.c	Tue Apr 12 17:44:34 2016	(r297863)
+++ head/sys/kern/kern_rctl.c	Tue Apr 12 18:13:24 2016	(r297864)
@@ -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);
 }
 
 /*


More information about the svn-src-all mailing list