summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-05-13 08:17:42 +0000
committerngie <ngie@FreeBSD.org>2016-05-13 08:17:42 +0000
commit8d808d7b779a395d962236552309cbafe956a3d2 (patch)
treef0a6ee323716d0780c9fecd40ff2f7fc33389256 /sys
parent6358713d891d38731f18bb70fba3d5e4666c19e4 (diff)
downloadFreeBSD-src-8d808d7b779a395d962236552309cbafe956a3d2.zip
FreeBSD-src-8d808d7b779a395d962236552309cbafe956a3d2.tar.gz
MFC r298333:
r298333 (by cem): 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. CID: 1305574
Diffstat (limited to 'sys')
-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 7a7c07a..fa772f5 100644
--- a/sys/sys/racct.h
+++ b/sys/sys/racct.h
@@ -92,7 +92,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
OpenPOWER on IntegriCloud