summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2016-02-25 14:12:14 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2016-03-03 18:24:12 -0800
commit82df003f36a405711ac41f2eb4e862f0878659e9 (patch)
tree0dd4920c929d5a5938918186454724155a903fb6
parent0744837f525d8ba103e807af7c44ad2bf5cbd6ca (diff)
downloadxorg-lib-libXext-82df003f36a405711ac41f2eb4e862f0878659e9.tar.gz
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 <alan.coopersmith@oracle.com>
-rw-r--r--src/XSecurity.c5
1 files changed, 5 insertions, 0 deletions
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 <X11/extensions/extutil.h>
#include <X11/extensions/securproto.h>
#include <X11/extensions/security.h>
+#include <assert.h>
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 */