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);
 }
 
 /*
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to