From 9017236525a644a60e0774d690e44086faa95eeb Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Sat, 7 Oct 2006 01:36:50 +0000 Subject: [PATCH] whitespace git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18662 dc483132-0cff-0310-8789-dd5450dbe970 --- src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c | 381 +++++++++---------- 1 file changed, 190 insertions(+), 191 deletions(-) diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c index ed82132b5..f7275916a 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c @@ -479,40 +479,40 @@ krb5_get_subtree_info(ldap_context, subtreearr, ntree) subtarr = (char **) malloc(sizeof(char *) * (subtreecount + 1 /*realm dn*/ + 1 /*containerref*/ + 1)); if (subtarr == NULL) { - st = ENOMEM; - goto cleanup; + st = ENOMEM; + goto cleanup; } memset(subtarr, 0, (sizeof(char *) * (subtreecount+1+1+1))); /* get the complete subtree list */ for (i=0; ilrparams->realmdn == NULL) { - st = EINVAL; - goto cleanup; + st = EINVAL; + goto cleanup; } - + len1 = strlen (ldap_context->lrparams->realmdn); len2 = strlen (policy_dn); if (len1 == 0 || len2 == 0 || len1 > len2) { - st = EINVAL; - goto cleanup; + st = EINVAL; + goto cleanup; } - + if (strcmp (ldap_context->lrparams->realmdn, policy_dn + (len2 - len1)) != 0) { - st = EINVAL; - goto cleanup; + st = EINVAL; + goto cleanup; } - + { - char *rdn; - LDAPDN dn; - rdn = strndup(policy_dn, len2 - len1 - 1); /* 1 character for ',' */ - - if (ldap_str2dn (rdn, &dn, LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PEDANTIC) != 0) { - st = EINVAL; - goto cleanup; - } - if (dn[0] == NULL || dn[1] != NULL) - st = EINVAL; - else if (strcasecmp (dn[0][0]->la_attr.bv_val, "cn") != 0) - st = EINVAL; - else - *name = strndup(dn[0][0]->la_value.bv_val, dn[0][0]->la_value.bv_len); - - ldap_memfree (dn); + char *rdn; + LDAPDN dn; + rdn = strndup(policy_dn, len2 - len1 - 1); /* 1 character for ',' */ + + if (ldap_str2dn (rdn, &dn, LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PEDANTIC) != 0) { + st = EINVAL; + goto cleanup; + } + if (dn[0] == NULL || dn[1] != NULL) + st = EINVAL; + else if (strcasecmp (dn[0][0]->la_attr.bv_val, "cn") != 0) + st = EINVAL; + else + *name = strndup(dn[0][0]->la_value.bv_val, dn[0][0]->la_value.bv_len); + + ldap_memfree (dn); } cleanup: return st; } - + krb5_error_code krb5_ldap_name_to_policydn (context, name, policy_dn) krb5_context context; char *name; @@ -1742,9 +1742,9 @@ krb5_error_code krb5_ldap_name_to_policydn (context, name, policy_dn) *policy_dn = NULL; /* validate the input parameters */ - if(name == NULL) { - st = EINVAL; - goto cleanup; + if (name == NULL) { + st = EINVAL; + goto cleanup; } /* Used for removing policy reference from an object */ @@ -1757,15 +1757,15 @@ krb5_error_code krb5_ldap_name_to_policydn (context, name, policy_dn) SETUP_CONTEXT(); if (ldap_context->lrparams->realmdn == NULL) { - st = EINVAL; - goto cleanup; + st = EINVAL; + goto cleanup; } len = strlen (ldap_context->lrparams->realmdn); ptr = ldap_filter_correct (name, strlen (name)); if (ptr == NULL) { - st = ENOMEM; - goto cleanup; + st = ENOMEM; + goto cleanup; } len += strlen (ptr); @@ -1773,20 +1773,20 @@ krb5_error_code krb5_ldap_name_to_policydn (context, name, policy_dn) *policy_dn = (char *) malloc (len); if (*policy_dn == NULL) { - st = ENOMEM; - goto cleanup; + st = ENOMEM; + goto cleanup; } sprintf (*policy_dn, "cn=%s,%s", ptr, ldap_context->lrparams->realmdn); cleanup: if (ptr != NULL) - free (ptr); + free (ptr); return st; } /* remove overlapping and repeated subtree entries from the list of subtrees */ -krb5_error_code remove_overlapping_subtrees( char **listin, char ***listop, int *subtcount, int sscope) +krb5_error_code remove_overlapping_subtrees(char **listin, char ***listop, int *subtcount, int sscope) { int slen=0, k=0, j=0, lendiff=0; int count = *subtcount; @@ -1794,55 +1794,54 @@ krb5_error_code remove_overlapping_subtrees( char **listin, char ***listop, int slen = count-1; for (k=0; k<=slen && listin[k]!=NULL ; k++) { - for (j=k+1; j<=slen && listin[j]!=NULL ;j++) { - lendiff = strlen(listin[k]) - strlen(listin[j]); - if (sscope == 2) { - if ((lendiff > 0) && (strcasecmp((listin[k])+lendiff, listin[j])==0)) { - if (k != slen ) { - free(listin[k]); - listin[k] = listin[slen]; - listin[slen] = NULL; - } else { - free(listin[k]); - listin[k] = NULL; - } - slen-=1; - k-=1; - break; - } - else if ((lendiff < 0) && (strcasecmp((listin[j])+lendiff, listin[k])==0)) { - if (j != slen ) { - free(listin[j]); - listin[j] = listin[slen]; - listin[slen]=NULL; - } else { - free(listin[j]); - listin[j] = NULL; - } - slen-=1; - j-=1; - } + for (j=k+1; j<=slen && listin[j]!=NULL ;j++) { + lendiff = strlen(listin[k]) - strlen(listin[j]); + if (sscope == 2) { + if ((lendiff > 0) && (strcasecmp((listin[k])+lendiff, listin[j])==0)) { + if (k != slen) { + free(listin[k]); + listin[k] = listin[slen]; + listin[slen] = NULL; + } else { + free(listin[k]); + listin[k] = NULL; + } + slen-=1; + k-=1; + break; + } else if ((lendiff < 0) && (strcasecmp((listin[j])+lendiff, listin[k])==0)) { + if (j != slen) { + free(listin[j]); + listin[j] = listin[slen]; + listin[slen]=NULL; + } else { + free(listin[j]); + listin[j] = NULL; + } + slen-=1; + j-=1; + } } - if ((lendiff == 0) && (strcasecmp(listin[j], listin[k])==0)) { - if (j != slen) { - free(listin[j]); - listin[j] = listin[slen]; - listin[slen]=NULL; - } else { - free(listin[j]); - listin[j] = NULL; - } - slen -=1; - j-=1; - } - } + if ((lendiff == 0) && (strcasecmp(listin[j], listin[k])==0)) { + if (j != slen) { + free(listin[j]); + listin[j] = listin[slen]; + listin[slen]=NULL; + } else { + free(listin[j]); + listin[j] = NULL; + } + slen -=1; + j-=1; + } + } } *subtcount=slen+1; - for(k=0; k<*subtcount && listin[k]!=NULL; k++) { - subtree[k] = strdup(listin[k]); - if (subtree[k] == NULL) { - return ENOMEM; - } + for (k=0; k<*subtcount && listin[k]!=NULL; k++) { + subtree[k] = strdup(listin[k]); + if (subtree[k] == NULL) { + return ENOMEM; + } } return 0; } -- 2.26.2