aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/racct.h
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2016-04-20 03:24:59 +0000
committerConrad Meyer <cem@FreeBSD.org>2016-04-20 03:24:59 +0000
commit8691cc73d11ecc262a437cc5d4361441515a6e84 (patch)
tree18996264a2301273a14a698fb7184d21efc582b1 /sys/sys/racct.h
parentc56482419371d3afdc02dcc76c5c9854fc1e118c (diff)
downloadsrc-8691cc73d11ecc262a437cc5d4361441515a6e84.tar.gz
src-8691cc73d11ecc262a437cc5d4361441515a6e84.zip
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
Notes
Notes: svn path=/head/; revision=298333
Diffstat (limited to 'sys/sys/racct.h')
-rw-r--r--sys/sys/racct.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/sys/racct.h b/sys/sys/racct.h
index 5330c637bf36..e50e7e67112c 100644
--- a/sys/sys/racct.h
+++ b/sys/sys/racct.h
@@ -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