From 780de03f009d9583541f6bbc6932b0c1b142231b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 27 Aug 2010 10:52:38 +1000 Subject: libcli/security Use ARRAY_SIZE() consistantly. This avoids the use of SE_END, and has all callers walking the array using the same termination condition. Andrew Bartlett Signed-off-by: Andrew Tridgell --- libcli/security/privileges.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'libcli/security') diff --git a/libcli/security/privileges.c b/libcli/security/privileges.c index 6acf72e7a0..c9756ab756 100644 --- a/libcli/security/privileges.c +++ b/libcli/security/privileges.c @@ -40,7 +40,6 @@ #undef strcasecmp const uint64_t se_priv_all = SE_ALL_PRIVS; -static const uint64_t se_priv_end = SE_END; /* Define variables for all privileges so we can use the uint64_t* in the various se_priv_XXX() functions */ @@ -73,7 +72,6 @@ PRIVS privs[] = { {SEC_PRIV_ADD_USERS, SE_ADD_USERS, "SeAddUsersPrivilege", "Add users and groups to the domain"}, {SEC_PRIV_DISK_OPERATOR, SE_DISK_OPERATOR, "SeDiskOperatorPrivilege", "Manage disk shares"}, - {0x0, SE_END, "", ""} }; /*************************************************************************** @@ -97,7 +95,7 @@ bool se_priv_copy( uint64_t *dst, const uint64_t *src ) bool se_priv_put_all_privileges(uint64_t *privilege_mask) { int i; - uint32_t num_privs = count_all_privileges(); + uint32_t num_privs = ARRAY_SIZE(privs); if (!se_priv_copy(privilege_mask, &se_priv_none)) { return false; @@ -172,7 +170,9 @@ bool se_priv_from_name( const char *name, uint64_t *privilege_mask ) { int i; - for ( i=0; !se_priv_equal(&privs[i].privilege_mask, &se_priv_end); i++ ) { + uint32_t num_privs = ARRAY_SIZE(privs); + + for ( i=0; ihigh != 0) return NULL; - for ( i=0; !se_priv_equal(&privs[i].privilege_mask, &se_priv_end); i++ ) { + for ( i=0; ilow == privs[i].luid ) { return privs[i].name; } @@ -390,7 +391,7 @@ static bool privilege_set_add(PRIVILEGE_SET *priv_set, struct lsa_LUIDAttribute bool se_priv_to_privilege_set( PRIVILEGE_SET *set, uint64_t *privilege_mask ) { int i; - uint32_t num_privs = count_all_privileges(); + uint32_t num_privs = ARRAY_SIZE(privs); struct lsa_LUIDAttribute luid; luid.attribute = 0; @@ -416,7 +417,7 @@ bool se_priv_to_privilege_set( PRIVILEGE_SET *set, uint64_t *privilege_mask ) static bool luid_to_se_priv( struct lsa_LUID *luid, uint64_t *privilege_mask ) { int i; - uint32_t num_privs = count_all_privileges(); + uint32_t num_privs = ARRAY_SIZE(privs); for ( i=0; ilow == privs[i].luid ) { -- cgit