summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/lib/libsldap/common/ns_crypt.c26
-rw-r--r--usr/src/lib/libsldap/common/ns_writes.c146
2 files changed, 83 insertions, 89 deletions
diff --git a/usr/src/lib/libsldap/common/ns_crypt.c b/usr/src/lib/libsldap/common/ns_crypt.c
index 69aa4b749e..49a708f9ee 100644
--- a/usr/src/lib/libsldap/common/ns_crypt.c
+++ b/usr/src/lib/libsldap/common/ns_crypt.c
@@ -83,8 +83,8 @@ static int
unhex(char c)
{
return (c >= '0' && c <= '9' ? c - '0'
- : c >= 'A' && c <= 'F' ? c - 'A' + 10
- : c - 'a' + 10);
+ : c >= 'A' && c <= 'F' ? c - 'A' + 10
+ : c - 'a' + 10);
}
@@ -98,7 +98,7 @@ ascii2hex(char *anHexaStr, int *aResLen)
return (NULL);
while (isxdigit(*anHexaStr)) {
theRes[theLen] = unhex(*anHexaStr) << 4;
- if (++anHexaStr != '\0') {
+ if (*(++anHexaStr) != '\0') {
theRes[theLen] += unhex(*anHexaStr);
anHexaStr++;
}
@@ -169,18 +169,20 @@ modvalue(char *str, int len, int *mod_len)
n2 = 0;
if ((s = (char *)malloc(2 * len + 1)) != NULL) {
while (i < len) {
- s[i] = t2[(t3[(t1[(str[i]+n1)&MASK]+n2)&MASK]-n2)&MASK]-n1;
- i++;
- n1++;
- if (n1 == ROTORSIZE) {
- n1 = 0;
- n2++;
- if (n2 == ROTORSIZE) n2 = 0;
- }
+ s[i] =
+ t2[(t3[(t1[(str[i]+n1)&MASK]+n2)&MASK]-n2)&MASK]-n1;
+ i++;
+ n1++;
+ if (n1 == ROTORSIZE) {
+ n1 = 0;
+ n2++;
+ if (n2 == ROTORSIZE)
+ n2 = 0;
+ }
}
s[i] = '\0';
if (mod_len != NULL)
- *mod_len = i;
+ *mod_len = i;
}
return (s);
}
diff --git a/usr/src/lib/libsldap/common/ns_writes.c b/usr/src/lib/libsldap/common/ns_writes.c
index 44f4570f38..5029598f19 100644
--- a/usr/src/lib/libsldap/common/ns_writes.c
+++ b/usr/src/lib/libsldap/common/ns_writes.c
@@ -69,9 +69,9 @@ static int escape_str(char *, char *);
/*
* If the rdn is a mapped attr:
- * return NS_LDAP_SUCCESS and a new_dn.
+ * return NS_LDAP_SUCCESS and a new_dn.
* If no mapped attr is found in the rdn:
- * return NS_LDAP_SUCCESS and *new_dn == NULL
+ * return NS_LDAP_SUCCESS and *new_dn == NULL
* For example:
* service = abc
* dn = cn=foo,dc=bar,dc=com
@@ -162,7 +162,7 @@ init_bval_mod(
int mop,
char *mtype,
char *mvptr,
- int mvlen)
+ int mvlen)
{
struct berval **bmodval;
@@ -657,16 +657,16 @@ __s_cvt_freeEntryRdn(ns_ldap_entry_t **entry, char **rdn)
*/
static int
write_state_machine(
- int ldap_op,
- char *dn,
+ int ldap_op,
+ char *dn,
LDAPMod **mods,
const ns_cred_t *cred,
- const int flags,
+ const int flags,
ns_ldap_error_t ** errorp)
{
ConnectionID connectionId = -1;
Connection *conp = NULL;
- LDAPMessage *res;
+ LDAPMessage *res;
char *target_dn = NULL;
char errstr[MAXERROR];
int rc = NS_LDAP_SUCCESS;
@@ -1523,7 +1523,7 @@ __s_mk_entry(char **objclass, int max_attr)
*/
static int
__s_cvt_passwd(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -1665,7 +1665,7 @@ static int escape_str(char *escstr, char *str)
*/
static int
__s_cvt_project(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -1675,7 +1675,7 @@ __s_cvt_project(const void *data, char **rdn,
struct project *ptr;
int max_attr = 9;
char ibuf[11];
- static char *oclist[] = {
+ static char *oclist[] = {
"SolarisProject",
"top",
NULL
@@ -1777,7 +1777,7 @@ __s_cvt_project(const void *data, char **rdn,
*/
static int
__s_cvt_shadow(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -1901,7 +1901,7 @@ __s_cvt_shadow(const void *data, char **rdn,
*/
static int
__s_cvt_group(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2005,7 +2005,7 @@ __s_cvt_group(const void *data, char **rdn,
*/
static int
__s_cvt_hosts(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2032,7 +2032,7 @@ __s_cvt_hosts(const void *data, char **rdn,
ptr = (struct hostent *)data;
if (ptr->h_name == NULL ||
- ptr->h_addr_list == NULL || ptr->h_addr_list[0] == '\0') {
+ ptr->h_addr_list == NULL || ptr->h_addr_list[0] == NULL) {
__ns_ldap_freeEntry(e);
*entry = NULL;
return (NS_LDAP_INVALID_PARAM);
@@ -2139,7 +2139,7 @@ __s_cvt_hosts(const void *data, char **rdn,
*/
static int
__s_cvt_rpc(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2229,7 +2229,7 @@ __s_cvt_rpc(const void *data, char **rdn,
*/
static int
__s_cvt_protocols(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2317,7 +2317,7 @@ __s_cvt_protocols(const void *data, char **rdn,
*/
static int
__s_cvt_services(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2344,7 +2344,7 @@ __s_cvt_services(const void *data, char **rdn,
/* Convert the structure */
ptr = (struct servent *)data;
- if (ptr->s_name == NULL || ptr->s_port < 0 || ptr->s_proto == '\0') {
+ if (ptr->s_name == NULL || ptr->s_port < 0 || ptr->s_proto == NULL) {
__ns_ldap_freeEntry(e);
*entry = NULL;
return (NS_LDAP_INVALID_PARAM);
@@ -2421,7 +2421,7 @@ __s_cvt_services(const void *data, char **rdn,
*/
static int
__s_cvt_networks(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2513,7 +2513,7 @@ __s_cvt_networks(const void *data, char **rdn,
*/
static int
__s_cvt_netmasks(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2552,13 +2552,13 @@ __s_cvt_netmasks(const void *data, char **rdn,
}
/* Error check the data and add the attributes */
- rc = __s_add_attr(e, "ipNetworkNumber", ptr->netnumber);
- if (rc != NS_LDAP_SUCCESS) {
- __s_cvt_freeEntryRdn(entry, rdn);
- return (rc);
- }
+ rc = __s_add_attr(e, "ipNetworkNumber", ptr->netnumber);
+ if (rc != NS_LDAP_SUCCESS) {
+ __s_cvt_freeEntryRdn(entry, rdn);
+ return (rc);
+ }
- if (ptr->netmask != '\0') {
+ if (ptr->netmask != NULL) {
rc = __s_add_attr(e, "ipNetmaskNumber", ptr->netmask);
if (rc != NS_LDAP_SUCCESS) {
__s_cvt_freeEntryRdn(entry, rdn);
@@ -2576,7 +2576,7 @@ __s_cvt_netmasks(const void *data, char **rdn,
*/
static int
__s_cvt_netgroups(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2601,7 +2601,7 @@ __s_cvt_netgroups(const void *data, char **rdn,
/* Convert the structure */
ptr = (struct _ns_netgroups *)data;
- if (ptr->name == NULL) {
+ if (ptr->name == NULL || *ptr->name == '\0') {
__ns_ldap_freeEntry(e);
*entry = NULL;
return (NS_LDAP_INVALID_PARAM);
@@ -2616,12 +2616,10 @@ __s_cvt_netgroups(const void *data, char **rdn,
return (NS_LDAP_MEMORY);
}
- if (ptr->name != '\0') {
- rc = __s_add_attr(e, "cn", ptr->name);
- if (rc != NS_LDAP_SUCCESS) {
- __s_cvt_freeEntryRdn(entry, rdn);
- return (rc);
- }
+ rc = __s_add_attr(e, "cn", ptr->name);
+ if (rc != NS_LDAP_SUCCESS) {
+ __s_cvt_freeEntryRdn(entry, rdn);
+ return (rc);
}
/* Error check the data and add the attributes */
@@ -2674,7 +2672,7 @@ __s_cvt_netgroups(const void *data, char **rdn,
*/
static int
__s_cvt_bootparams(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2700,7 +2698,7 @@ __s_cvt_bootparams(const void *data, char **rdn,
/* Convert the structure */
ptr = (struct _ns_bootp *)data;
- if (ptr->name == NULL) {
+ if (ptr->name == NULL || *ptr->name == '\0') {
__ns_ldap_freeEntry(e);
*entry = NULL;
return (NS_LDAP_INVALID_PARAM);
@@ -2715,12 +2713,10 @@ __s_cvt_bootparams(const void *data, char **rdn,
return (NS_LDAP_MEMORY);
}
- if (ptr->name != '\0') {
- rc = __s_add_attr(e, "cn", ptr->name);
- if (rc != NS_LDAP_SUCCESS) {
- __s_cvt_freeEntryRdn(entry, rdn);
- return (rc);
- }
+ rc = __s_add_attr(e, "cn", ptr->name);
+ if (rc != NS_LDAP_SUCCESS) {
+ __s_cvt_freeEntryRdn(entry, rdn);
+ return (rc);
}
/* Error check the data and add the attributes */
@@ -2755,7 +2751,7 @@ __s_cvt_bootparams(const void *data, char **rdn,
*/
static int
__s_cvt_ethers(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2779,7 +2775,7 @@ __s_cvt_ethers(const void *data, char **rdn,
/* Convert the structure */
ptr = (struct _ns_ethers *)data;
- if (ptr->name == NULL || ptr->ether == '\0') {
+ if (ptr->name == NULL || *ptr->name == '\0' || ptr->ether == NULL) {
__ns_ldap_freeEntry(e);
*entry = NULL;
return (NS_LDAP_INVALID_PARAM);
@@ -2928,7 +2924,7 @@ modify_ethers_bootp(
*/
static int
__s_cvt_publickey(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -2950,7 +2946,8 @@ __s_cvt_publickey(const void *data, char **rdn,
/* Convert the structure */
ptr = (struct _ns_pubkey *)data;
- if (ptr->name == NULL || ptr->pubkey == '\0' || ptr->privkey == '\0') {
+ if (ptr->name == NULL || *ptr->name == '\0' || ptr->pubkey == NULL ||
+ ptr->privkey == NULL) {
__ns_ldap_freeEntry(e);
*entry = NULL;
return (NS_LDAP_INVALID_PARAM);
@@ -2991,7 +2988,7 @@ __s_cvt_publickey(const void *data, char **rdn,
*/
static int
__s_cvt_aliases(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -3016,7 +3013,7 @@ __s_cvt_aliases(const void *data, char **rdn,
/* Convert the structure */
ptr = (struct _ns_alias *)data;
- if (ptr->alias == NULL) {
+ if (ptr->alias == NULL || *ptr->alias == '\0') {
__ns_ldap_freeEntry(e);
*entry = NULL;
return (NS_LDAP_INVALID_PARAM);
@@ -3031,12 +3028,10 @@ __s_cvt_aliases(const void *data, char **rdn,
return (NS_LDAP_MEMORY);
}
- if (ptr->alias != '\0') {
- rc = __s_add_attr(e, "mail", (char *)ptr->alias);
- if (rc != NS_LDAP_SUCCESS) {
- __s_cvt_freeEntryRdn(entry, rdn);
- return (rc);
- }
+ rc = __s_add_attr(e, "mail", (char *)ptr->alias);
+ if (rc != NS_LDAP_SUCCESS) {
+ __s_cvt_freeEntryRdn(entry, rdn);
+ return (rc);
}
/* Error check the data and add the attributes */
@@ -3071,7 +3066,7 @@ __s_cvt_aliases(const void *data, char **rdn,
*/
static int
__s_cvt_auto_mount(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -3114,7 +3109,8 @@ __s_cvt_auto_mount(const void *data, char **rdn,
/* Convert the structure */
ptr = (struct _ns_automount *)data;
- if (ptr->key == NULL || ptr->value == '\0' || ptr->mapname == '\0') {
+ if (ptr->key == NULL || *ptr->key == '\0' || ptr->value == NULL ||
+ ptr->mapname == NULL) {
__ns_ldap_freeEntry(e);
*entry = NULL;
return (NS_LDAP_INVALID_PARAM);
@@ -3130,13 +3126,11 @@ __s_cvt_auto_mount(const void *data, char **rdn,
return (NS_LDAP_MEMORY);
}
- if (ptr->key != '\0') {
- rc = __s_add_attr(e, version1 ? "cn" : "automountKey",
- (char *)ptr->key);
- if (rc != NS_LDAP_SUCCESS) {
- __s_cvt_freeEntryRdn(entry, rdn);
- return (rc);
- }
+ rc = __s_add_attr(e, version1 ? "cn" : "automountKey",
+ (char *)ptr->key);
+ if (rc != NS_LDAP_SUCCESS) {
+ __s_cvt_freeEntryRdn(entry, rdn);
+ return (rc);
}
rc = __s_add_attr(e, version1 ? "nisMapEntry" : "automountInformation",
@@ -3174,7 +3168,7 @@ __s_cvt_auto_mount(const void *data, char **rdn,
*/
static int
__s_cvt_authattr(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -3266,7 +3260,7 @@ __s_cvt_authattr(const void *data, char **rdn,
*/
static int
__s_cvt_execattr(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -3377,7 +3371,7 @@ __s_cvt_execattr(const void *data, char **rdn,
*/
static int
__s_cvt_profattr(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -3461,7 +3455,7 @@ __s_cvt_profattr(const void *data, char **rdn,
*/
static int
__s_cvt_userattr(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -3543,7 +3537,7 @@ __s_cvt_userattr(const void *data, char **rdn,
*/
static int
__s_cvt_audituser(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -3610,7 +3604,7 @@ __s_cvt_audituser(const void *data, char **rdn,
*/
static int
__s_cvt_tnrhtp(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -3680,7 +3674,7 @@ __s_cvt_tnrhtp(const void *data, char **rdn,
*/
static int
__s_cvt_tnrhdb(const void *data, char **rdn,
- ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
+ ns_ldap_entry_t **entry, ns_ldap_error_t **errorp)
{
ns_ldap_entry_t *e;
int rc;
@@ -3793,7 +3787,7 @@ int __ns_ldap_addTypedEntry(
{
char *rdn = NULL, *fulldn = NULL;
void **paramVal = NULL;
- ns_ldap_entry_t *entry = NULL;
+ ns_ldap_entry_t *entry = NULL;
const ns_ldap_attr_t *const *modattrlist;
ns_ldap_search_desc_t **sdlist;
char **dns = NULL;
@@ -3973,11 +3967,9 @@ int __ns_ldap_addTypedEntry(
* SSD = service:ou=foo,
*/
int
-__s_api_append_default_basedn(
- const char *dn,
- char **new_dn,
- int *allocated,
- ns_ldap_error_t **errp) {
+__s_api_append_default_basedn(const char *dn, char **new_dn, int *allocated,
+ ns_ldap_error_t **errp)
+{
int rc = NS_LDAP_SUCCESS, len = 0;
void **param = NULL;
@@ -3990,7 +3982,7 @@ __s_api_append_default_basedn(
return (NS_LDAP_INVALID_PARAM);
rc = __ns_ldap_getParam(NS_LDAP_SEARCH_BASEDN_P,
- (void ***)&param, errp);
+ (void ***)&param, errp);
if (rc != NS_LDAP_SUCCESS) {
if (param)