Date: Wed, 20 Apr 2016 03:24:59 +0000 (UTC) From: "Conrad E. Meyer" <cem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298333 - head/sys/sys Message-ID: <201604200324.u3K3OxfF064788@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cem Date: Wed Apr 20 03:24:59 2016 New Revision: 298333 URL: https://svnweb.freebsd.org/changeset/base/298333 Log: Make Racct macro slightly more gracious given RACCT_UNDEFINED rctl_string_to_rule could previously index below the zeroth element of racct_types via the macro. Maybe it shouldn't use the macro on RACCT_UNDEFINED. But given every other RACCT_ definition is non-negative, it seems pretty easy to foot-shoot this one without the check. Reported by: Coverity CID: 1305574 Sponsored by: EMC / Isilon Storage Division Modified: head/sys/sys/racct.h Modified: head/sys/sys/racct.h ============================================================================== --- head/sys/sys/racct.h Wed Apr 20 03:05:32 2016 (r298332) +++ head/sys/sys/racct.h Wed Apr 20 03:24:59 2016 (r298333) @@ -99,7 +99,8 @@ extern int racct_enable; * visible to the userland. It gets fixed up when retrieving resource * usage or adding rules. */ -#define RACCT_IS_IN_MILLIONS(X) (racct_types[X] & RACCT_IN_MILLIONS) +#define RACCT_IS_IN_MILLIONS(X) \ + ((X) != RACCT_UNDEFINED && (racct_types[(X)] & RACCT_IN_MILLIONS) != 0) /* * Resource usage can drop, as opposed to only grow. When the process
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604200324.u3K3OxfF064788>