From: Tom Yu Date: Fri, 22 Dec 2006 04:28:09 +0000 (+0000) Subject: pull up r19009 from trunk X-Git-Tag: krb5-1.6-beta2~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0d3c882765df6a67ac267c70f7c371ef13b55ebe;p=krb5.git pull up r19009 from trunk r19009@cathode-dark-space: raeburn | 2006-12-21 20:26:59 -0500 ticket: 4453 target_version: 1.6 tags: pullup Some related changes were already in, and I found a couple more to make: * ldap_realm.c (ldap_filter_correct): Change string argument to char *. Delete length argument, which was always strlen of the string argument, and compute it locally, using size_t instead of (unsigned) int for length-related values. Update all calls. * ldap_realm.h (ldap_filter_correct): Updated declaration. * ldap_misc.c (remove_overlapping_subtrees): Add forward declaration. Make static. (is_principal_in_realm): Change local variable defrealmlen to size_t. (store_tl_data): Change local variable curr to point to unsigned char, since that's what the tl_data_contents array is declared as, and what the STORE16_INT macro is happier with. (krb5_ldap_get_reference_count): Make local variable i unsigned. ticket: 4453 version_fixed: 1.6 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@19010 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c index 19730defa..11c5caae3 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c @@ -45,6 +45,10 @@ extern char *strptime (const char *, const char *, struct tm *); #endif +static krb5_error_code +remove_overlapping_subtrees(char **listin, char **listop, int *subtcount, + int sscope); + /* Linux (GNU Libc) provides a length-limited variant of strdup. But all the world's not Linux. */ #undef strndup @@ -418,7 +422,7 @@ is_principal_in_realm(ldap_context, searchfor) krb5_ldap_context *ldap_context; krb5_const_principal searchfor; { - int defrealmlen=0; + size_t defrealmlen=0; char *defrealm=NULL; #define FIND_MAX(a,b) ((a) > (b) ? (a) : (b)) @@ -569,7 +573,7 @@ store_tl_data(tl_data, tl_type, value) void *value; { unsigned int currlen=0, tldatalen=0; - char *curr=NULL; + unsigned char *curr=NULL; void *reallocptr=NULL; tl_data->tl_data_type = KDB_TL_USER_INFO; @@ -592,7 +596,7 @@ store_tl_data(tl_data, tl_type, value) free (reallocptr); return ENOMEM; } - curr = (char *) (tl_data->tl_data_contents + currlen); + curr = (tl_data->tl_data_contents + currlen); /* store the tl_type value */ memset(curr, tl_type, 1); @@ -623,7 +627,7 @@ store_tl_data(tl_data, tl_type, value) free (reallocptr); return ENOMEM; } - curr = (char *) (tl_data->tl_data_contents + currlen); + curr = (tl_data->tl_data_contents + currlen); /* store the tl_type value */ memset(curr, tl_type, 1); @@ -1609,8 +1613,8 @@ krb5_error_code krb5_ldap_get_reference_count (krb5_context context, char *dn, char *refattr, int *count, LDAP *ld) { - int i, st = 0, tempst = 0, gothandle = 0; - unsigned int ntrees; + int st = 0, tempst = 0, gothandle = 0; + unsigned int i, ntrees; char *refcntattr[2]; char *filter = NULL; char **subtree = NULL, *ptr = NULL; @@ -1634,7 +1638,7 @@ krb5_ldap_get_reference_count (krb5_context context, char *dn, char *refattr, refcntattr [0] = refattr; refcntattr [1] = NULL; - ptr = ldap_filter_correct (dn, strlen (dn)); + ptr = ldap_filter_correct (dn); if (ptr == NULL) { st = ENOMEM; goto cleanup; @@ -1809,7 +1813,7 @@ krb5_error_code krb5_ldap_name_to_policydn (context, name, policy_dn) } len = strlen (ldap_context->lrparams->realmdn); - ptr = ldap_filter_correct (name, strlen (name)); + ptr = ldap_filter_correct (name); if (ptr == NULL) { st = ENOMEM; goto cleanup; @@ -1833,7 +1837,7 @@ cleanup: } /* remove overlapping and repeated subtree entries from the list of subtrees */ -krb5_error_code +static krb5_error_code remove_overlapping_subtrees(char **listin, char **listop, int *subtcount, int sscope) { int slen=0, k=0, j=0, lendiff=0; diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c index 760b7df29..3ab49dbc1 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c @@ -74,10 +74,11 @@ char *krbContainerRefclass[] = { "krbContainerRefAux", NULL}; * Function to remove all special characters from a string (rfc2254). * Use whenever exact matching is to be done ... */ -char *ldap_filter_correct (unsigned char *in, unsigned int len) +char *ldap_filter_correct (char *in) { - int i, count; + size_t i, count; char *out, *ptr; + size_t len = strlen(in); for (i = 0, count = 0; i < len; i++) switch (in[i]) { @@ -283,7 +284,7 @@ krb5_ldap_delete_realm (context, lrealm) char *attr[] = {"krbprincipalname", NULL}, *realm=NULL, filter[256]; krb5_ldap_context lcontext; - realm = ldap_filter_correct (lrealm, strlen (lrealm)); + realm = ldap_filter_correct (lrealm); assert (sizeof (filter) >= sizeof ("(krbprincipalname=)") + strlen (realm) + 2 /* "*@" */ + 1); diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.h b/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.h index faff3ffbb..ffe6c3665 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.h +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.h @@ -94,6 +94,6 @@ krb5_error_code krb5_ldap_delete_realm_1(krb5_context, char *, char **); char * -ldap_filter_correct(unsigned char *, unsigned int); +ldap_filter_correct(char *); #endif