From 82df003f36a405711ac41f2eb4e862f0878659e9 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 25 Feb 2016 14:12:14 -0800 Subject: Assert that values buffer has enough room for provided values Catch if anyone ever defines more types again and forgets to increase the size of the value buffer to match. v2: assert on the full set of possible values, regardless of which the current caller passed in this call - more likely to be spotted during testing, less likely to not be found until called in production. Signed-off-by: Alan Coopersmith --- src/XSecurity.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/XSecurity.c b/src/XSecurity.c index d0a68d2..3ca75b1 100644 --- a/src/XSecurity.c +++ b/src/XSecurity.c @@ -33,6 +33,7 @@ in this Software without prior written authorization from The Open Group. #include #include #include +#include static XExtensionInfo _Security_info_data; static XExtensionInfo *Security_info = &_Security_info_data; @@ -221,6 +222,10 @@ XSecurityGenerateAuthorization( unsigned long *value = values; unsigned int nvalues; + /* values array must have a slot for each possible valuemask value */ + assert(Ones(XSecurityAllAuthorizationAttributes) + == (sizeof(values) / sizeof(values[0]))); + *auth_id_return = 0; /* in case we fail */ /* make sure extension is available */ -- cgit v1.2.3