Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 May 2016 08:17:42 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r299616 - stable/10/sys/sys
Message-ID:  <201605130817.u4D8HglP058654@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Fri May 13 08:17:42 2016
New Revision: 299616
URL: https://svnweb.freebsd.org/changeset/base/299616

Log:
  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

Modified:
  stable/10/sys/sys/racct.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/sys/racct.h
==============================================================================
--- stable/10/sys/sys/racct.h	Fri May 13 08:04:57 2016	(r299615)
+++ stable/10/sys/sys/racct.h	Fri May 13 08:17:42 2016	(r299616)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605130817.u4D8HglP058654>