Date: Tue, 12 Apr 2016 18:13:25 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r297864 - head/sys/kern Message-ID: <201604121813.u3CIDPwL090839@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604121813.u3CIDPwL090839>