From f2a9089e4df315608a18b42daf999cd40791abf6 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 17 Dec 2003 20:55:46 +0000 Subject: [PATCH] cleanup most of the -pedantic warnings (ITS#2884) and other small fixes --- servers/slapd/acl.c | 4 ++ servers/slapd/controls.c | 8 ++- servers/slapd/ldapsync.c | 1 + servers/slapd/result.c | 2 +- servers/slapd/saslauthz.c | 9 +++- servers/slapd/schema_init.c | 98 +++++++++++++++++++------------------ servers/slapd/sessionlog.c | 3 +- 7 files changed, 72 insertions(+), 53 deletions(-) diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index c68fe36a35..06d9d762b3 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -36,6 +36,10 @@ #include "sets.h" #include "lber_pvt.h" +#ifdef LDAP_SLAPI +#include "slapi.h" +#endif /* LDAPI_SLAPI */ + #define ACL_BUF_SIZE 1024 /* use most appropriate size */ /* diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index 530857c478..eed5c8bd79 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -752,11 +752,17 @@ static int parseProxyAuthz ( { int rc; char buf[ SLAP_LDAPDN_MAXLEN ]; - struct berval id = { ctrl->ldctl_value.bv_len, (char *)buf }, + struct berval id, user = { 0, NULL }, realm = { 0, NULL }, mech = { 0, NULL }; + if ( sizeof( buf ) <= ctrl->ldctl_value.bv_len ) { + return LDAP_INVALID_SYNTAX; + } + + id.bv_len = ctrl->ldctl_value.bv_len; + id.bv_val = buf; strncpy( buf, ctrl->ldctl_value.bv_val, sizeof( buf ) ); rc = slap_parse_user( &id, &user, &realm, &mech ); diff --git a/servers/slapd/ldapsync.c b/servers/slapd/ldapsync.c index 7241f1318e..2d87f64fa4 100644 --- a/servers/slapd/ldapsync.c +++ b/servers/slapd/ldapsync.c @@ -435,6 +435,7 @@ slap_parse_sync_cookie( } else { cookie->rid = -1; } + return 0; } int diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 2374d94b56..1b8a9dda42 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -289,7 +289,7 @@ send_ldap_response( { BerElementBuffer berbuf; BerElement *ber = (BerElement *) &berbuf; - int rc; + int rc = LDAP_SUCCESS; long bytes; if (op->o_callback) { diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index 4ad85482eb..1bf2af2a30 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -266,7 +266,7 @@ is_dn: bv.bv_len = uri->bv_len - (bv.bv_val - uri->bv_val); { Connection c = *op->o_conn; char buf[ SLAP_LDAPDN_MAXLEN ]; - struct berval id = { uri->bv_len, (char *)buf }, + struct berval id, user = { 0, NULL }, realm = { 0, NULL }, mech = { 0, NULL }; @@ -275,6 +275,8 @@ is_dn: bv.bv_len = uri->bv_len - (bv.bv_val - uri->bv_val); return LDAP_INVALID_SYNTAX; } + id.bv_len = uri->bv_len; + id.bv_val = buf; strncpy( buf, uri->bv_val, sizeof( buf ) ); rc = slap_parse_user( &id, &user, &realm, &mech ); @@ -642,7 +644,10 @@ exact_match: goto exact_match; } else if ( d > 0 ) { - struct berval bv = { op.o_req_ndn.bv_len, assertDN->bv_val + d }; + struct berval bv; + + bv.bv_len = op.o_req_ndn.bv_len; + bv.bv_val = assertDN->bv_val + d; if ( bv.bv_val[ -1 ] == ',' && dn_match( &op.o_req_ndn, &bv ) ) { rc = LDAP_SUCCESS; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 8369a43204..8a70eaefbb 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -97,7 +97,7 @@ sequenceValidate( static int certificateValidate( Syntax *syntax, struct berval *in ) { X509 *xcert=NULL; - unsigned char *p = in->bv_val; + unsigned char *p = (unsigned char *)in->bv_val; xcert = d2i_X509(NULL, &p, in->bv_len); if ( !xcert ) return LDAP_INVALID_SYNTAX; @@ -167,7 +167,7 @@ int octetStringIndexer( HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval digest; - digest.bv_val = HASHdigest; + digest.bv_val = (char *)HASHdigest; digest.bv_len = sizeof(HASHdigest); for( i=0; values[i].bv_val != NULL; i++ ) { @@ -186,14 +186,15 @@ int octetStringIndexer( HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { HASH_Update( &HASHcontext, - prefix->bv_val, prefix->bv_len ); + (unsigned char *)prefix->bv_val, + prefix->bv_len ); } HASH_Update( &HASHcontext, - syntax->ssyn_oid, slen ); + (unsigned char *)syntax->ssyn_oid, slen ); HASH_Update( &HASHcontext, - mr->smr_oid, mlen ); + (unsigned char *)mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - values[i].bv_val, values[i].bv_len ); + (unsigned char *)values[i].bv_val, values[i].bv_len ); HASH_Final( HASHdigest, &HASHcontext ); ber_dupbv_x( &keys[i], &digest, ctx ); @@ -224,7 +225,7 @@ int octetStringFilter( unsigned char HASHdigest[HASH_BYTES]; struct berval *value = (struct berval *) assertedValue; struct berval digest; - digest.bv_val = HASHdigest; + digest.bv_val = (char *)HASHdigest; digest.bv_len = sizeof(HASHdigest); slen = syntax->ssyn_oidlen; @@ -235,14 +236,14 @@ int octetStringFilter( HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { HASH_Update( &HASHcontext, - prefix->bv_val, prefix->bv_len ); + (unsigned char *)prefix->bv_val, prefix->bv_len ); } HASH_Update( &HASHcontext, - syntax->ssyn_oid, slen ); + (unsigned char *)syntax->ssyn_oid, slen ); HASH_Update( &HASHcontext, - mr->smr_oid, mlen ); + (unsigned char *)mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - value->bv_val, value->bv_len ); + (unsigned char *)value->bv_val, value->bv_len ); HASH_Final( HASHdigest, &HASHcontext ); ber_dupbv_x( keys, &digest, ctx ); @@ -397,7 +398,7 @@ octetStringSubstringsIndexer( HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval digest; - digest.bv_val = HASHdigest; + digest.bv_val = (char *)HASHdigest; digest.bv_len = sizeof(HASHdigest); nkeys=0; @@ -460,17 +461,17 @@ octetStringSubstringsIndexer( HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { HASH_Update( &HASHcontext, - prefix->bv_val, prefix->bv_len ); + (unsigned char *)prefix->bv_val, prefix->bv_len ); } HASH_Update( &HASHcontext, - &pre, sizeof( pre ) ); + (unsigned char *)&pre, sizeof( pre ) ); HASH_Update( &HASHcontext, - syntax->ssyn_oid, slen ); + (unsigned char *)syntax->ssyn_oid, slen ); HASH_Update( &HASHcontext, - mr->smr_oid, mlen ); + (unsigned char *)mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - &values[i].bv_val[j], + (unsigned char *)&values[i].bv_val[j], SLAP_INDEX_SUBSTR_MAXLEN ); HASH_Final( HASHdigest, &HASHcontext ); @@ -489,16 +490,16 @@ octetStringSubstringsIndexer( HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { HASH_Update( &HASHcontext, - prefix->bv_val, prefix->bv_len ); + (unsigned char *)prefix->bv_val, prefix->bv_len ); } HASH_Update( &HASHcontext, - &pre, sizeof( pre ) ); + (unsigned char *)&pre, sizeof( pre ) ); HASH_Update( &HASHcontext, - syntax->ssyn_oid, slen ); + (unsigned char *)syntax->ssyn_oid, slen ); HASH_Update( &HASHcontext, - mr->smr_oid, mlen ); + (unsigned char *)mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - values[i].bv_val, j ); + (unsigned char *)values[i].bv_val, j ); HASH_Final( HASHdigest, &HASHcontext ); ber_dupbv_x( &keys[nkeys++], &digest, ctx ); @@ -509,16 +510,16 @@ octetStringSubstringsIndexer( HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { HASH_Update( &HASHcontext, - prefix->bv_val, prefix->bv_len ); + (unsigned char *)prefix->bv_val, prefix->bv_len ); } HASH_Update( &HASHcontext, - &pre, sizeof( pre ) ); + (unsigned char *)&pre, sizeof( pre ) ); HASH_Update( &HASHcontext, - syntax->ssyn_oid, slen ); + (unsigned char *)syntax->ssyn_oid, slen ); HASH_Update( &HASHcontext, - mr->smr_oid, mlen ); + (unsigned char *)mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - &values[i].bv_val[values[i].bv_len-j], j ); + (unsigned char *)&values[i].bv_val[values[i].bv_len-j], j ); HASH_Final( HASHdigest, &HASHcontext ); ber_dupbv_x( &keys[nkeys++], &digest, ctx ); @@ -590,7 +591,7 @@ octetStringSubstringsFilter ( return LDAP_SUCCESS; } - digest.bv_val = HASHdigest; + digest.bv_val = (char *)HASHdigest; digest.bv_len = sizeof(HASHdigest); slen = syntax->ssyn_oidlen; @@ -611,16 +612,16 @@ octetStringSubstringsFilter ( HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { HASH_Update( &HASHcontext, - prefix->bv_val, prefix->bv_len ); + (unsigned char *)prefix->bv_val, prefix->bv_len ); } HASH_Update( &HASHcontext, - &pre, sizeof( pre ) ); + (unsigned char *)&pre, sizeof( pre ) ); HASH_Update( &HASHcontext, - syntax->ssyn_oid, slen ); + (unsigned char *)syntax->ssyn_oid, slen ); HASH_Update( &HASHcontext, - mr->smr_oid, mlen ); + (unsigned char *)mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - value->bv_val, klen ); + (unsigned char *)value->bv_val, klen ); HASH_Final( HASHdigest, &HASHcontext ); ber_dupbv_x( &keys[nkeys++], &digest, ctx ); @@ -645,16 +646,16 @@ octetStringSubstringsFilter ( HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { HASH_Update( &HASHcontext, - prefix->bv_val, prefix->bv_len ); + (unsigned char *)prefix->bv_val, prefix->bv_len ); } HASH_Update( &HASHcontext, - &pre, sizeof( pre ) ); + (unsigned char *)&pre, sizeof( pre ) ); HASH_Update( &HASHcontext, - syntax->ssyn_oid, slen ); + (unsigned char *)syntax->ssyn_oid, slen ); HASH_Update( &HASHcontext, - mr->smr_oid, mlen ); + (unsigned char *)mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - &value->bv_val[j], klen ); + (unsigned char *)&value->bv_val[j], klen ); HASH_Final( HASHdigest, &HASHcontext ); ber_dupbv_x( &keys[nkeys++], &digest, ctx ); @@ -674,16 +675,16 @@ octetStringSubstringsFilter ( HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { HASH_Update( &HASHcontext, - prefix->bv_val, prefix->bv_len ); + (unsigned char *)prefix->bv_val, prefix->bv_len ); } HASH_Update( &HASHcontext, - &pre, sizeof( pre ) ); + (unsigned char *)&pre, sizeof( pre ) ); HASH_Update( &HASHcontext, - syntax->ssyn_oid, slen ); + (unsigned char *)syntax->ssyn_oid, slen ); HASH_Update( &HASHcontext, - mr->smr_oid, mlen ); + (unsigned char *)mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - &value->bv_val[value->bv_len-klen], klen ); + (unsigned char *)&value->bv_val[value->bv_len-klen], klen ); HASH_Final( HASHdigest, &HASHcontext ); ber_dupbv_x( &keys[nkeys++], &digest, ctx ); @@ -1116,7 +1117,7 @@ UTF8StringValidate( { ber_len_t count; int len; - unsigned char *u = in->bv_val; + unsigned char *u = (unsigned char *)in->bv_val; if( in->bv_len == 0 && syntax == slap_schema.si_syn_directoryString ) { /* directory strings cannot be empty */ @@ -1158,7 +1159,7 @@ UTF8StringValidate( /* make sure len corresponds with the offset to the next character */ - if( LDAP_UTF8_OFFSET( u ) != len ) return LDAP_INVALID_SYNTAX; + if( LDAP_UTF8_OFFSET( (char *)u ) != len ) return LDAP_INVALID_SYNTAX; } if( count != 0 ) { @@ -1819,7 +1820,7 @@ UUIDNormalize( struct berval *normalized, void *ctx ) { - unsigned char octet; + unsigned char octet = '\0'; int i; int j; normalized->bv_len = 16; @@ -2222,7 +2223,7 @@ certificateExactNormalize( assert( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX(usage) ); - p = val->bv_val; + p = (unsigned char *)val->bv_val; xcert = d2i_X509( NULL, &p, val->bv_len); if( xcert == NULL ) goto done; @@ -2238,7 +2239,8 @@ certificateExactNormalize( if( rc != LDAP_SUCCESS ) goto done; normalized->bv_len = seriallen + issuer_dn.bv_len + 1; - p = normalized->bv_val = ch_malloc(normalized->bv_len+1); + normalized->bv_val = ch_malloc(normalized->bv_len+1); + p = (unsigned char *)normalized->bv_val; AC_MEMCPY(p, serial, seriallen); p += seriallen; *p++ = '$'; diff --git a/servers/slapd/sessionlog.c b/servers/slapd/sessionlog.c index d2b1242a54..9cc3a45a65 100644 --- a/servers/slapd/sessionlog.c +++ b/servers/slapd/sessionlog.c @@ -45,7 +45,7 @@ slap_send_session_log( uuid_attr[0].an_desc = NULL; uuid_attr[0].an_oc = NULL; - uuid_attr[0].an_oc_exclude = NULL; + uuid_attr[0].an_oc_exclude = 0; uuid_attr[0].an_name.bv_len = 0; uuid_attr[0].an_name.bv_val = NULL; e.e_attrs = NULL; @@ -94,6 +94,7 @@ slap_send_session_log( rs->sr_ctrls = NULL; } } + return LDAP_SUCCESS; } int -- 2.39.5