瀏覽代碼

204517 - Use new ber types throughout the server code.

Nathan Kinder 19 年之前
父節點
當前提交
e5be59676d

+ 1 - 1
ldap/servers/plugins/acl/aclproxy.c

@@ -85,7 +85,7 @@ parse_LDAPProxyAuth(struct berval *spec_ber, int version, char **errtextp,
 
 
   BEGIN
-    unsigned long tag;
+    ber_tag_t tag;
 
 	if ( version != 1 && version != 2 ) {
 		break;

+ 1 - 1
ldap/servers/plugins/chainingdb/cb_controls.c

@@ -144,7 +144,7 @@ int cb_update_controls( Slapi_PBlock * pb,
     cb_backend           * cbb;
     Slapi_Backend        * be;
     int rc=LDAP_SUCCESS;
-    long hops=0;
+    ber_int_t hops=0;
     int useloop=0;
     int addauth = (ctrl_flags & CB_UPDATE_CONTROLS_ADDAUTH);
     int isabandon = (ctrl_flags & CB_UPDATE_CONTROLS_ISABANDON);

+ 2 - 2
ldap/servers/plugins/chainingdb/cb_utils.c

@@ -176,7 +176,7 @@ int cb_forward_operation(Slapi_PBlock * pb ) {
 			/* Decode control data 			*/
 			/* hop           INTEGER (0 .. maxInt) 	*/
 
-			long 		hops = 0;
+			ber_int_t	hops = 0;
 			int 		rc;
 			BerElement 	*ber = NULL;
 
@@ -193,7 +193,7 @@ int cb_forward_operation(Slapi_PBlock * pb ) {
 				return LDAP_LOOP_DETECT;
 			}
 				
-			if (hops <=0) {
+			if (hops <= 0) {
        				slapi_log_error(SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
 					"Max hop count exceeded. Loop detected.\n");
         			ber_free(ber,1);

+ 25 - 25
ldap/servers/plugins/replication/repl5_total.c

@@ -468,16 +468,16 @@ static int
 my_ber_scanf_value(BerElement *ber, Slapi_Value **value, PRBool *deleted)
 {
 	struct berval *attrval = NULL;
-	unsigned long len;
-    unsigned long tag;
-    CSN *csn = NULL;
-    char csnstring[CSN_STRSIZE + 1];
+	ber_len_t len;
+	ber_tag_t tag;
+	CSN *csn = NULL;
+	char csnstring[CSN_STRSIZE + 1];
 	CSNType csntype;
-    char *lasti;
+	char *lasti;
 
 	PR_ASSERT(ber && value && deleted);
 
-    *value = NULL;
+	*value = NULL;
 
 	if (NULL == ber && NULL == value)
 	{
@@ -486,7 +486,7 @@ my_ber_scanf_value(BerElement *ber, Slapi_Value **value, PRBool *deleted)
 	}
 
 	/* Each value is a sequence */
-	if (ber_scanf(ber, "{O", &attrval) == -1)
+	if (ber_scanf(ber, "{O", &attrval) == LBER_ERROR)
 	{
 		slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "my_ber_scanf_value BAD 2\n");
 		goto loser;
@@ -501,7 +501,7 @@ my_ber_scanf_value(BerElement *ber, Slapi_Value **value, PRBool *deleted)
     /* check if this is a deleted value */
     if (ber_peek_tag(ber, &len) == LBER_BOOLEAN)
     {
-        if (ber_scanf(ber, "b", deleted) == -1)
+        if (ber_scanf(ber, "b", deleted) == LBER_ERROR)
 		{
 			slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "my_ber_scanf_value BAD 4\n");
 			goto loser;
@@ -518,10 +518,10 @@ my_ber_scanf_value(BerElement *ber, Slapi_Value **value, PRBool *deleted)
 		tag != LBER_ERROR && tag != LBER_END_OF_SEQORSET;
 		tag = ber_next_element(ber, &len, lasti))
 	{
-		long csntype_tmp;
+		ber_int_t csntype_tmp;
 		/* Each CSN is in a sequence that includes a csntype and CSN */
 		len = CSN_STRSIZE;
-		if (ber_scanf(ber, "{es}", &csntype_tmp, csnstring, &len) == -1)
+		if (ber_scanf(ber, "{es}", &csntype_tmp, csnstring, &len) == LBER_ERROR)
 		{
 			slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "my_ber_scanf_value BAD 7 - bval is %s\n", attrval->bv_val);
 			goto loser;
@@ -552,7 +552,7 @@ my_ber_scanf_value(BerElement *ber, Slapi_Value **value, PRBool *deleted)
         csn_free (&csn);
 	}
 
-	if (ber_scanf(ber, "}") == -1) /* End of annotated attribute value seq */
+	if (ber_scanf(ber, "}") == LBER_ERROR) /* End of annotated attribute value seq */
 	{
 		slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "my_ber_scanf_value BAD 10\n");
 		goto loser;
@@ -580,11 +580,11 @@ static int
 my_ber_scanf_attr (BerElement *ber, Slapi_Attr **attr, PRBool *deleted)
 {
     char *attrtype = NULL;
-	CSN *attr_deletion_csn = NULL;
+    CSN *attr_deletion_csn = NULL;
     PRBool val_deleted;
     char *lasti;
-    unsigned long len;
-	unsigned long tag;
+    ber_len_t len;
+    ber_tag_t tag;
     char *str = NULL;
     int rc;
     Slapi_Value *value;
@@ -598,7 +598,7 @@ my_ber_scanf_attr (BerElement *ber, Slapi_Attr **attr, PRBool *deleted)
         goto loser;
     }
 
-	if (ber_scanf(ber, "{a", &attrtype) == -1) /* Begin sequence for this attr */
+	if (ber_scanf(ber, "{a", &attrtype) == LBER_ERROR) /* Begin sequence for this attr */
 	{
 		goto loser;
 	}
@@ -610,7 +610,7 @@ my_ber_scanf_attr (BerElement *ber, Slapi_Attr **attr, PRBool *deleted)
 	/* The attribute deletion CSN is next and is optional? */
     if (ber_peek_tag(ber, &len) == LBER_OCTETSTRING)
     {
-	    if (ber_scanf(ber, "a", &str) == -1)
+	    if (ber_scanf(ber, "a", &str) == LBER_ERROR)
 	    {
 		    goto loser;
 	    }
@@ -673,7 +673,7 @@ my_ber_scanf_attr (BerElement *ber, Slapi_Attr **attr, PRBool *deleted)
 			slapi_value_free(&value);
 	}	
 
-	if (ber_scanf(ber, "}") == -1) /* End sequence for this attribute */
+	if (ber_scanf(ber, "}") == LBER_ERROR) /* End sequence for this attribute */
 	{
 		goto loser;
 	}
@@ -701,16 +701,16 @@ decode_total_update_extop(Slapi_PBlock *pb, Slapi_Entry **ep)
 {
 	BerElement *tmp_bere = NULL;
 	Slapi_Entry *e = NULL;
-    Slapi_Attr *attr = NULL;
+	Slapi_Attr *attr = NULL;
 	char *str = NULL;
 	CSN *dn_csn = NULL;
 	struct berval *extop_value = NULL;
 	char *extop_oid = NULL;
-	unsigned long len;
+	ber_len_t len;
 	char *lasto;
-	unsigned long tag;
+	ber_tag_t tag;
 	int rc;
-    PRBool deleted;
+	PRBool deleted;
 	
 	PR_ASSERT(NULL != pb);
 	PR_ASSERT(NULL != ep);
@@ -737,13 +737,13 @@ decode_total_update_extop(Slapi_PBlock *pb, Slapi_Entry **ep)
 		goto loser;
 	}
 
-	if (ber_scanf(tmp_bere, "{") == -1) /* Begin outer sequence */
+	if (ber_scanf(tmp_bere, "{") == LBER_ERROR) /* Begin outer sequence */
 	{
 		goto loser;
 	}
 
 	/* The entry's uniqueid is first */
-	if (ber_scanf(tmp_bere, "a", &str) == -1)
+	if (ber_scanf(tmp_bere, "a", &str) == LBER_ERROR)
 	{
 		goto loser;
 	}
@@ -751,7 +751,7 @@ decode_total_update_extop(Slapi_PBlock *pb, Slapi_Entry **ep)
 	str = NULL;	/* Slapi_Entry now owns the uniqueid */
 
 	/* The entry's DN is next */
-	if (ber_scanf(tmp_bere, "a", &str) == -1)
+	if (ber_scanf(tmp_bere, "a", &str) == LBER_ERROR)
 	{
 		goto loser;
 	}
@@ -777,7 +777,7 @@ decode_total_update_extop(Slapi_PBlock *pb, Slapi_Entry **ep)
         attr = NULL;
 	}
 
-    if (ber_scanf(tmp_bere, "}") == -1) /* End sequence for this entry */
+    if (ber_scanf(tmp_bere, "}") == LBER_ERROR) /* End sequence for this entry */
 	{
 		goto loser;
 	}

+ 9 - 8
ldap/servers/plugins/replication/repl_controls.c

@@ -205,7 +205,7 @@ decode_NSDS50ReplUpdateInfoControl(LDAPControl **controlsp,
 	BerElement *tmp_bere = NULL;
 	Slapi_Mods modrdn_smods;
 	PRBool got_modrdn_mods = PR_FALSE;
-	unsigned long len;
+	ber_len_t len;
 
 	slapi_mods_init(&modrdn_smods, 4);
 	if (slapi_control_present(controlsp, REPL_NSDS50_UPDATE_INFO_CONTROL_OID,
@@ -216,7 +216,7 @@ decode_NSDS50ReplUpdateInfoControl(LDAPControl **controlsp,
 			rc = -1;
 			goto loser;
 		}
-		if (ber_scanf(tmp_bere, "{oo", &uuid_val, &csn_val) == -1)
+		if (ber_scanf(tmp_bere, "{oo", &uuid_val, &csn_val) == LBER_ERROR)
 		{
 			rc = -1;
 			goto loser;
@@ -232,7 +232,8 @@ decode_NSDS50ReplUpdateInfoControl(LDAPControl **controlsp,
 		}
 		if (ber_peek_tag(tmp_bere, &len) == LBER_SEQUENCE)
 		{
-			unsigned long emtag, emlen;
+			ber_tag_t emtag;
+			ber_len_t emlen;
 			char *emlast;
 
 			for ( emtag = ber_first_element( tmp_bere, &emlen, &emlast );
@@ -240,7 +241,7 @@ decode_NSDS50ReplUpdateInfoControl(LDAPControl **controlsp,
 				  emtag = ber_next_element( tmp_bere, &emlen, emlast ))
 			{
 				struct berval **embvals;
-				long op;
+				ber_int_t op;
 				char *type;
 				if ( ber_scanf( tmp_bere, "{i{a[V]}}", &op, &type, &embvals ) == LBER_ERROR )
 				{
@@ -253,7 +254,7 @@ decode_NSDS50ReplUpdateInfoControl(LDAPControl **controlsp,
 			}
 			got_modrdn_mods = PR_TRUE;
 		}
-		if (ber_scanf(tmp_bere, "}") == -1)
+		if (ber_scanf(tmp_bere, "}") == LBER_ERROR)
 		{
 			rc = -1;
 			goto loser;
@@ -337,10 +338,10 @@ add_repl_control_mods( Slapi_PBlock *pb, Slapi_Mods *smods )
     	if ( embvp != NULL && embvp->bv_len > 0 && embvp->bv_val != NULL )
     	{
     	    /* Parse the extramods stuff */
-    	    long op;
+    	    ber_int_t op;
     	    char *type;
-    	    unsigned long emlen;
-    	    unsigned long emtag;
+    	    ber_len_t emlen;
+    	    ber_tag_t emtag;
     	    char *emlast;
     	    BerElement *ember = ber_init( embvp );
     	    if ( ember != NULL )

+ 11 - 10
ldap/servers/plugins/replication/repl_extop.c

@@ -300,7 +300,7 @@ decode_startrepl_extop(Slapi_PBlock *pb, char **protocol_oid, char **repl_root,
 	char *extop_oid = NULL;
 	struct berval *extop_value = NULL;
 	BerElement *tmp_bere = NULL;
-	unsigned long len;
+	ber_len_t len;
 	int rc = 0;
 
     PR_ASSERT (pb && protocol_oid && repl_root && supplier_ruv && extra_referrals && csnstr);
@@ -328,7 +328,7 @@ decode_startrepl_extop(Slapi_PBlock *pb, char **protocol_oid, char **repl_root,
 		rc = -1;
 		goto free_and_return;
 	}
-	if (ber_scanf(tmp_bere, "{") == -1)
+	if (ber_scanf(tmp_bere, "{") == LBER_ERROR)
 	{
 		rc = -1;
 		goto free_and_return;
@@ -355,7 +355,7 @@ decode_startrepl_extop(Slapi_PBlock *pb, char **protocol_oid, char **repl_root,
 	/* Get the optional set of referral URLs */
 	if (ber_peek_tag(tmp_bere, &len) == LBER_SET)
 	{
-		if (ber_scanf(tmp_bere, "[v]", extra_referrals) == -1)
+		if (ber_scanf(tmp_bere, "[v]", extra_referrals) == LBER_ERROR)
 		{
 			rc = -1;
 			goto free_and_return;
@@ -364,13 +364,13 @@ decode_startrepl_extop(Slapi_PBlock *pb, char **protocol_oid, char **repl_root,
 	/* Get the optional CSN */
 	if (ber_peek_tag(tmp_bere, &len) == LBER_OCTETSTRING)
 	{
-		if (ber_get_stringa(tmp_bere, csnstr) == -1)
+		if (ber_get_stringa(tmp_bere, csnstr) == LBER_ERROR)
 		{
 			rc = -1;
 			goto free_and_return;
 		}
 	}
-	if (ber_scanf(tmp_bere, "}") == -1)
+	if (ber_scanf(tmp_bere, "}") == LBER_ERROR)
 	{
 		rc = -1;
 		goto free_and_return;
@@ -488,24 +488,25 @@ decode_repl_ext_response(struct berval *data, int *response_code,
 	}
 	else
 	{
-		unsigned long len, tag = 0;
-		long temp_response_code = 0;
+		ber_len_t len;
+		ber_tag_t tag = 0;
+		ber_int_t temp_response_code = 0;
 		*ruv_bervals = NULL;
 		if ((tmp_bere = ber_init(data)) == NULL)
 		{
 			return_value = -1;
 		}
-		else if (ber_scanf(tmp_bere, "{e", &temp_response_code) == -1)
+		else if (ber_scanf(tmp_bere, "{e", &temp_response_code) == LBER_ERROR)
 		{
 			return_value = -1;
 		}
 		else if ((tag = ber_peek_tag(tmp_bere, &len)) == LBER_SEQUENCE)
 		{
-			if (ber_scanf(tmp_bere, "{V}}", ruv_bervals) == -1)
+			if (ber_scanf(tmp_bere, "{V}}", ruv_bervals) == LBER_ERROR)
 			{
 				return_value = -1;
 			}
-		} else if (ber_scanf(tmp_bere, "}") == -1)
+		} else if (ber_scanf(tmp_bere, "}") == LBER_ERROR)
 		{
 			return_value = -1;
 		}

+ 2 - 2
ldap/servers/plugins/replication/windows_private.c

@@ -460,8 +460,8 @@ void windows_private_update_dirsync_control(const Repl_Agmt *ra,LDAPControl **co
 	int i;
 	LDAPControl *dirsync;
 	BerElement *ber;
-	long hasMoreData;
-	long maxAttributeCount;
+	ber_int_t hasMoreData;
+	ber_int_t maxAttributeCount;
 	BerValue  *serverCookie;
 	int return_value = LDAP_SUCCESS;
 

+ 3 - 4
ldap/servers/slapd/abandon.c

@@ -59,8 +59,8 @@
 void
 do_abandon( Slapi_PBlock *pb )
 {
-	int			id, err, suppressed_by_plugin = 0;
-	long			long_id;
+	int		err, suppressed_by_plugin = 0;
+	ber_int_t	id;
 	Operation	*o;
 	BerElement	*ber = pb->pb_op->o_ber;
 
@@ -72,13 +72,12 @@ do_abandon( Slapi_PBlock *pb )
 	 *	AbandonRequest := MessageID
 	 */
 
-	if ( ber_scanf( ber, "i", &long_id ) == LBER_ERROR ) {
+	if ( ber_scanf( ber, "i", &id ) == LBER_ERROR ) {
 		LDAPDebug( LDAP_DEBUG_ANY,
 		    "ber_scanf failed (op=Abandon; params=ID)\n",
 		    0, 0 ,0 );
 		return;
 	}
-	id=long_id;
 
 	slapi_pblock_set( pb, SLAPI_ABANDON_MSGID, &id );
 

+ 4 - 3
ldap/servers/slapd/add.c

@@ -74,10 +74,11 @@ do_add( Slapi_PBlock *pb )
 	Slapi_Operation *operation;
 	BerElement		*ber;
 	char			*last;
-	unsigned long	len, tag;
+	ber_len_t		len;
+	ber_tag_t		tag;
 	Slapi_Entry		*e = NULL;
-	int				err;
-	int				rc;
+	int			err;
+	int			rc;
 	char			ebuf[ BUFSIZ ];
 	PRBool  searchsubentry=PR_TRUE;
 

+ 8 - 8
ldap/servers/slapd/back-ldbm/proto-back-ldbm.h

@@ -458,19 +458,19 @@ int ldbm_back_dbmonitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
  */
 struct vlv_request
 {
-    unsigned long beforeCount;
-    unsigned long afterCount;
-    unsigned long tag;
-    unsigned long index;
-    unsigned long contentCount;
+    ber_uint_t beforeCount;
+    ber_uint_t afterCount;
+    ber_tag_t tag;
+    ber_uint_t index;
+    ber_uint_t contentCount;
     struct berval value;
 };
 
 struct vlv_response
 {
-    unsigned long targetPosition;
-    unsigned long contentCount;
-    unsigned long result;
+    ber_uint_t targetPosition;
+    ber_uint_t contentCount;
+    ber_uint_t result;
 };
 
 int vlv_init(ldbm_instance *inst);

+ 5 - 5
ldap/servers/slapd/back-ldbm/sort.c

@@ -290,7 +290,7 @@ make_sort_response_control ( Slapi_PBlock *pb, int code, char *error_type) {
 }
 /* End fix for bug #394184 */
 
-static int term_tag(unsigned long tag)
+static int term_tag(ber_tag_t tag)
 {
 	return ( (LBER_END_OF_SEQORSET == tag) || (LBER_ERROR == tag) );
 }
@@ -353,8 +353,8 @@ int parse_sort_spec(struct berval *sort_spec_ber, sort_spec **ps)
 	*/
 	BerElement *ber = NULL;
 	sort_spec_thing *listhead = NULL;
-	unsigned long tag = 0;
-	unsigned long len = 0;
+	ber_tag_t tag = 0;
+	ber_len_t len = 0;
 	char *last = NULL;
 	sort_spec_thing *listpointer = NULL;
 	char *type = NULL;
@@ -374,9 +374,9 @@ int parse_sort_spec(struct berval *sort_spec_ber, sort_spec **ps)
 		char *inner_last = NULL;
 		char *rtype = NULL;
 		int reverse = 0;
-		unsigned long next_tag = 0;
+		ber_tag_t next_tag = 0;
 		sort_spec_thing *s = NULL;
-    	unsigned long return_value;
+		ber_tag_t return_value;
 
 		next_tag = ber_first_element( ber, &len, &inner_last );
 

+ 62 - 67
ldap/servers/slapd/back-ldbm/vlv.c

@@ -821,13 +821,13 @@ determine_result_range(const struct vlv_request *vlv_request_control, PRUint32 i
             *pstart= index - vlv_request_control->beforeCount;
         }
         /* Make sure we don't run off the end */
-        if(ULONG_MAX - index > vlv_request_control->afterCount)
+        if(UINT_MAX - index > vlv_request_control->afterCount)
         {
             *pstop= index + vlv_request_control->afterCount;
         }
         else
         {
-            *pstop= ULONG_MAX;
+            *pstop= UINT_MAX;
         }
         /* Client tried to index off the end */
         if (0 == length) /* 609377: index size could be 0 */
@@ -1403,7 +1403,7 @@ vlv_trim_candidates_byindex(PRUint32 length, const struct vlv_request *vlv_reque
             }
             else
             {
-                /* The three components of this expression are (PRUint32) and may well have a value up to ULONG_MAX */
+                /* The three components of this expression are (PRUint32) and may well have a value up to UINT_MAX */
                 /* SelectedIndex = ActualContentCount * ( ClientIndex / ClientContentCount ) */
                 si= ((PRUint32)((double)length * (double)(vlv_request_control->index / (double)vlv_request_control->contentCount )));
             }
@@ -1633,7 +1633,7 @@ vlv_make_response_control (Slapi_PBlock *pb, const struct vlv_response* vlvp)
         ber_bvfree(bvp);
     }
 
-	LDAPDebug( LDAP_DEBUG_TRACE, "<= vlv_make_response_control: Index=%lu Size=%lu Result=%lu\n", vlvp->targetPosition, vlvp->contentCount, vlvp->result );
+	LDAPDebug( LDAP_DEBUG_TRACE, "<= vlv_make_response_control: Index=%u Size=%u Result=%u\n", vlvp->targetPosition, vlvp->contentCount, vlvp->result );
 
 	return (rc==-1?LDAP_OPERATIONS_ERROR:LDAP_SUCCESS);
 }
@@ -1655,7 +1655,7 @@ void vlv_print_access_log(Slapi_PBlock *pb,struct vlv_request* vlvi, struct vlv_
 	p+= sprintf(p,"VLV ");
 	if (0 == vlvi->tag) {
 		/* By Index case */
-		p+= sprintf(p,"%ld:%ld:%ld:%ld",
+		p+= sprintf(p,"%u:%u:%u:%u",
 			vlvi->beforeCount ,
 			vlvi->afterCount ,
 			vlvi->index ,
@@ -1672,7 +1672,7 @@ void vlv_print_access_log(Slapi_PBlock *pb,struct vlv_request* vlvi, struct vlv_
 		}
         strncpy(string,vlvi->value.bv_val,vlvi->value.bv_len);
         string[vlvi->value.bv_len] = '\0';
-		p += sprintf(p,"%ld:%ld:%s",
+		p += sprintf(p,"%u:%u:%s",
 			vlvi->beforeCount ,
 			vlvi->afterCount ,
 			string
@@ -1682,7 +1682,7 @@ void vlv_print_access_log(Slapi_PBlock *pb,struct vlv_request* vlvi, struct vlv_
 		}
 	}
 	/* Now the response info */
-	p += sprintf(p," %ld:%ld (%ld)",
+	p += sprintf(p," %u:%u (%u)",
 		vlvo->targetPosition ,
 		vlvo->contentCount,
 		vlvo->result
@@ -1720,82 +1720,77 @@ vlv_parse_request_control( backend *be, struct berval *vlv_spec_ber,struct vlv_r
                      contentCount    INTEGER (0 .. maxInt) }
                      greaterThanOrEqual [1] assertionValue }
    	*/
-	BerElement *ber = NULL;
-	int return_value = LDAP_SUCCESS;
-	PRUint32 rc= 0;
-	long long_beforeCount;
-	long long_afterCount;
-	long long_index;
-	long long_contentCount;
+    BerElement *ber = NULL;
+    int return_value = LDAP_SUCCESS;
 	
-	vlvp->value.bv_len = 0;
-	vlvp->value.bv_val = NULL;
-
-	ber = ber_init(vlv_spec_ber);
-	rc = ber_scanf(ber,"{ii",&long_beforeCount,&long_afterCount);
-	vlvp->beforeCount = long_beforeCount;
-	vlvp->afterCount = long_afterCount;
-	if (LBER_ERROR == rc)
-	{
+    vlvp->value.bv_len = 0;
+    vlvp->value.bv_val = NULL;
+
+    ber = ber_init(vlv_spec_ber);
+    if (ber_scanf(ber, "{ii", &vlvp->beforeCount, &vlvp->afterCount) == LBER_ERROR)
+    {
         return_value= LDAP_OPERATIONS_ERROR;
     }
     else
     {
-        LDAPDebug( LDAP_DEBUG_TRACE, "vlv_parse_request_control: Before=%lu After=%lu\n", vlvp->beforeCount, vlvp->afterCount, 0 );
-           rc = ber_scanf(ber,"t",&vlvp->tag);
-        switch(vlvp->tag)
+        LDAPDebug( LDAP_DEBUG_TRACE, "vlv_parse_request_control: Before=%u After=%u\n",
+                   vlvp->beforeCount, vlvp->afterCount, 0 );
+        if (ber_scanf(ber,"t",&vlvp->tag) == LBER_ERROR)
         {
-        case LDAP_TAG_VLV_BY_INDEX:
-            /* byIndex */
-            vlvp->tag= 0;
-            rc = ber_scanf(ber,"{ii}}",&long_index,&long_contentCount);
-            vlvp->index = long_index;
-            vlvp->contentCount = long_contentCount;
-            if (LBER_ERROR == rc)
+            return_value= LDAP_OPERATIONS_ERROR;
+        }
+        else
+        {
+            switch(vlvp->tag)
             {
-                if (ISLEGACY(be)) {
-                    return_value = LDAP_OPERATIONS_ERROR;
-                } else {
-                    return_value = LDAP_VIRTUAL_LIST_VIEW_ERROR;
+            case LDAP_TAG_VLV_BY_INDEX:
+                /* byIndex */
+                vlvp->tag= 0;
+                if (ber_scanf(ber, "{ii}}", &vlvp->index, &vlvp->contentCount) == LBER_ERROR)
+                {
+                    if (ISLEGACY(be)) {
+                        return_value = LDAP_OPERATIONS_ERROR;
+                    } else {
+                        return_value = LDAP_VIRTUAL_LIST_VIEW_ERROR;
+                    }
                 }
-            }
-            else
-            {
-                /* Client Counts from 1. */
-                if(vlvp->index!=0)
+                else
                 {
-                    vlvp->index--;
+                    /* Client Counts from 1. */
+                    if(vlvp->index!=0)
+                    {
+                        vlvp->index--;
+                    }
+                    LDAPDebug( LDAP_DEBUG_TRACE, "vlv_parse_request_control: Index=%lu Content=%lu\n", vlvp->index, vlvp->contentCount, 0 );
                 }
-                LDAPDebug( LDAP_DEBUG_TRACE, "vlv_parse_request_control: Index=%lu Content=%lu\n", vlvp->index, vlvp->contentCount, 0 );
-            }
-            break;
-        case LDAP_TAG_VLV_BY_VALUE:
-            /* byValue */
-            vlvp->tag= 1;
-            rc = ber_scanf(ber,"o}",&vlvp->value);
-            if (LBER_ERROR == rc)
-            {
+                break;
+            case LDAP_TAG_VLV_BY_VALUE:
+                /* byValue */
+                vlvp->tag= 1;
+                if (ber_scanf(ber,"o}",&vlvp->value) == LBER_ERROR)
+                {
+                    if (ISLEGACY(be)) {
+                        return_value = LDAP_OPERATIONS_ERROR;
+                    } else {
+                        return_value = LDAP_VIRTUAL_LIST_VIEW_ERROR;
+                    }
+                }
+                {
+                    /* jcm: isn't there a utility fn to do this? */
+                    char *p= slapi_ch_malloc(vlvp->value.bv_len+1);
+                    strncpy(p,vlvp->value.bv_val,vlvp->value.bv_len);
+                    p[vlvp->value.bv_len]= '\0';
+                    LDAPDebug( LDAP_DEBUG_TRACE, "vlv_parse_request_control: Value=%s\n", p, 0, 0 );
+                    slapi_ch_free( (void**)&p);
+                }
+                break;
+            default:
                 if (ISLEGACY(be)) {
                     return_value = LDAP_OPERATIONS_ERROR;
                 } else {
                     return_value = LDAP_VIRTUAL_LIST_VIEW_ERROR;
                 }
             }
-            {
-            /* jcm: isn't there a utility fn to do this? */
-            char *p= slapi_ch_malloc(vlvp->value.bv_len+1);
-            strncpy(p,vlvp->value.bv_val,vlvp->value.bv_len);
-            p[vlvp->value.bv_len]= '\0';
-               LDAPDebug( LDAP_DEBUG_TRACE, "vlv_parse_request_control: Value=%s\n", p, 0, 0 );
-            slapi_ch_free( (void**)&p);
-            }
-            break;
-        default:
-            if (ISLEGACY(be)) {
-                return_value = LDAP_OPERATIONS_ERROR;
-            } else {
-                return_value = LDAP_VIRTUAL_LIST_VIEW_ERROR;
-            }
         }
     }
 

+ 6 - 8
ldap/servers/slapd/bind.c

@@ -106,15 +106,15 @@ void
 do_bind( Slapi_PBlock *pb )
 {
     BerElement	*ber = pb->pb_op->o_ber;
-    int		err, version = -1, method = -1, isroot;
-    long 	long_method = -1;
-    long ber_version = -1;
+    int		err, isroot;
+    ber_tag_t 	method = LBER_DEFAULT;
+    ber_int_t	version = -1;
     int		auth_response_requested = 0;
     int		pw_response_requested = 0;
     char		*dn = NULL, *saslmech = NULL;
     struct berval	cred = {0};
     Slapi_Backend		*be = NULL;
-    unsigned long rc;
+    ber_tag_t rc;
     Slapi_DN sdn;
     Slapi_Entry *referral;
     char errorbuf[BUFSIZ];
@@ -144,9 +144,7 @@ do_bind( Slapi_PBlock *pb )
      *	}
      */
 
-    rc = ber_scanf( ber, "{iat", &ber_version, &dn, &long_method );
-    method = long_method;
-    version = ber_version;
+    rc = ber_scanf( ber, "{iat", &version, &dn, &method );
     if ( rc == LBER_ERROR ) {
         LDAPDebug( LDAP_DEBUG_ANY,
                    "ber_scanf failed (op=Bind; params=Version,DN,Method)\n",
@@ -182,7 +180,7 @@ do_bind( Slapi_PBlock *pb )
         /* Get the (optional) SASL credentials */
         if ( rc != LBER_ERROR ) {
             /* Credentials are optional in SASL bind */
-            unsigned long clen;
+            ber_len_t clen;
             if (( ber_peek_tag( ber, &clen )) == LBER_OCTETSTRING ) {
                 rc = ber_scanf( ber, "o}}", &cred );
             } else {

+ 27 - 26
ldap/servers/slapd/connection.c

@@ -61,9 +61,9 @@ static Slapi_PBlock *get_pb( void );
 static void connection_add_operation(Connection* conn, Operation *op);
 static void connection_free_private_buffer(Connection *conn);
 static void op_copy_identity(Connection *conn, Operation *op);
-static int is_ber_too_big(const Connection *conn,unsigned long ber_len);
+static int is_ber_too_big(const Connection *conn, ber_len_t ber_len);
 static void log_ber_too_big_error(const Connection *conn,
-				unsigned long ber_len, unsigned long maxbersize);
+				ber_len_t ber_len, ber_len_t maxbersize);
 static int add_to_select_set(Connection *conn);
 
 /*
@@ -792,10 +792,11 @@ static int handle_read_data(Connection *conn,Operation **op,
 static int process_operation(Connection *conn, Operation *op)
 {
 	Slapi_PBlock	*pb = NULL;
-	unsigned long	len, tag;
-	long		msgid;
+	ber_len_t	len;
+	ber_tag_t	tag;
+	ber_int_t	msgid;
 	int return_value = 0;
-    int destroy_content = 1;
+	int destroy_content = 1;
 
 
 	pb = (Slapi_PBlock *) slapi_ch_calloc( 1, sizeof(Slapi_PBlock) );
@@ -1008,10 +1009,10 @@ static int read_the_data(Connection *conn, int *process_op, int *defer_io, int *
 	Operation *op = NULL;
 	DWORD Bytes_Read = 0;
 	char *Buffer = NULL;
-	int tag = 0;
+	ber_tag_t tag = 0;
 	int return_value = -1;
-	unsigned long ber_len = 0;
-	unsigned long Bytes_Scanned = 0;
+	ber_len_t ber_len = 0;
+	ber_len_t Bytes_Scanned = 0;
 
 	*defer_io = 0;
 	*defer_pushback = 0;
@@ -1583,12 +1584,12 @@ void connection_make_new_pb(Slapi_PBlock	**ppb, Connection	*conn)
  * small wrapper on top of libldap's ber_get_next_buffer_ext().
  */
 static int
-get_next_from_buffer( void *buffer, size_t buffer_size, unsigned long *lenp,
-    unsigned long *tagp, BerElement *ber, Connection *conn )
+get_next_from_buffer( void *buffer, size_t buffer_size, ber_len_t *lenp,
+    ber_tag_t *tagp, BerElement *ber, Connection *conn )
 {
 	PRErrorCode		err = 0;
 	PRInt32			syserr = 0;
-	unsigned long	bytes_scanned = 0;
+	ber_len_t		bytes_scanned = 0;
 
 	*lenp = 0;
 	*tagp = ber_get_next_buffer_ext( buffer, buffer_size, lenp, ber,
@@ -1645,12 +1646,12 @@ connection_read_ldap_data(Connection *conn, PRInt32 *err)
    by buffering the data and setting the 'remaining_data' flag.
 
  */
-int connection_read_operation(Connection *conn, Operation *op, unsigned long *tag, int *remaining_data)
+int connection_read_operation(Connection *conn, Operation *op, ber_tag_t *tag, int *remaining_data)
 {
-	unsigned long	len = 0;
-	int ret = 0;
-	int waits_done = 0;
-	long		msgid;
+	ber_len_t	len = 0;
+	int		ret = 0;
+	int		waits_done = 0;
+	ber_int_t	msgid;
 	int new_operation = 1; /* Are we doing the first I/O read for a new operation ? */
 	char *buffer = conn->c_private->c_buffer;
 	PRErrorCode err = 0;
@@ -1968,7 +1969,7 @@ connection_threadmain()
 	PRIntervalTime	interval = PR_SecondsToInterval(10);
 	Connection	*conn = NULL;
 	Operation	*op;
-	unsigned long	tag = 0;
+	ber_tag_t	tag = 0;
 	int need_wakeup;
 	int thread_turbo_flag = 0;
 	int ret = 0;
@@ -2342,7 +2343,7 @@ connection_remove_operation( Connection *conn, Operation *op )
 	if ( *tmp == NULL )
 	{
 		LDAPDebug( LDAP_DEBUG_ANY, "connection_remove_operation: can't find op %d for conn %d\n",
-		    op->o_msgid, conn->c_connid, 0 );
+		    (int)op->o_msgid, conn->c_connid, 0 );
 	}
 	else
 	{
@@ -2426,10 +2427,10 @@ op_copy_identity(Connection *conn, Operation *op)
 
 
 static int
-is_ber_too_big(const Connection *conn,unsigned long ber_len)
+is_ber_too_big(const Connection *conn, ber_len_t ber_len)
 {
-    unsigned long maxbersize= config_get_maxbersize();
-    if(ber_len>maxbersize)
+    ber_len_t maxbersize= config_get_maxbersize();
+    if(ber_len > maxbersize)
 	{
 		log_ber_too_big_error(conn, ber_len, maxbersize);
 		return 1;
@@ -2444,8 +2445,8 @@ is_ber_too_big(const Connection *conn,unsigned long ber_len)
  * logged.
  */
 static void
-log_ber_too_big_error(const Connection *conn, unsigned long ber_len,
-		unsigned long maxbersize)
+log_ber_too_big_error(const Connection *conn, ber_len_t ber_len,
+		ber_len_t maxbersize)
 {
 	if (0 == maxbersize) {
 		maxbersize= config_get_maxbersize();
@@ -2453,13 +2454,13 @@ log_ber_too_big_error(const Connection *conn, unsigned long ber_len,
 	if (0 == ber_len) {
 		slapi_log_error( SLAPI_LOG_FATAL, "connection",
 			"conn=%d fd=%d Incoming BER Element was too long, max allowable"
-			" is %ld bytes. Change the nsslapd-maxbersize attribute in"
+			" is %u bytes. Change the nsslapd-maxbersize attribute in"
 			" cn=config to increase.\n",
 			conn->c_connid, conn->c_sd, maxbersize );
 	} else {
 		slapi_log_error( SLAPI_LOG_FATAL, "connection",
-			"conn=%d fd=%d Incoming BER Element was %ld bytes, max allowable"
-			" is %ld bytes. Change the nsslapd-maxbersize attribute in"
+			"conn=%d fd=%d Incoming BER Element was %u bytes, max allowable"
+			" is %u bytes. Change the nsslapd-maxbersize attribute in"
 			" cn=config to increase.\n",
 			conn->c_connid, conn->c_sd, ber_len, maxbersize );
 	}

+ 1 - 1
ldap/servers/slapd/conntable.c

@@ -58,7 +58,7 @@ connection_table_new(int table_size)
 	for ( i = 0; i < table_size; i++ )
 	{
 		int	invalid_socket;
-        unsigned long maxbersize= config_get_maxbersize();
+		ber_len_t maxbersize = config_get_maxbersize();
 		/* DBDB---move this out of here once everything works */
 		ct->c[i].c_sb = ber_sockbuf_alloc();
 		invalid_socket = SLAPD_INVALID_SOCKET;

+ 2 - 1
ldap/servers/slapd/control.c

@@ -187,7 +187,8 @@ get_ldapmessage_controls(
 )
 {
 	LDAPControl		**ctrls, *new;
-	unsigned long		tag, len;
+	ber_tag_t		tag;
+	ber_len_t		len;
 	int			rc, maxcontrols, curcontrols;
 	char			*last;
 	int			managedsait, pwpolicy_ctrl;

+ 5 - 4
ldap/servers/slapd/extendop.c

@@ -214,11 +214,12 @@ static void extop_handle_import_done(Slapi_PBlock *pb, char *extoid,
 void
 do_extended( Slapi_PBlock *pb )
 {
-	char			*extoid = NULL,	*errmsg;
+	char		*extoid = NULL,	*errmsg;
 	struct berval	extval = {0};
-	int				lderr, rc;
-	unsigned long	len, tag;
-	const char		*name;
+	int		lderr, rc;
+	ber_len_t	len;
+	ber_tag_t	tag;
+	const char	*name;
 
 	LDAPDebug( LDAP_DEBUG_TRACE, "do_extended\n", 0, 0, 0 );
 

+ 18 - 10
ldap/servers/slapd/filter.c

@@ -172,7 +172,7 @@ get_filter_internal( Connection *conn, BerElement *ber,
 	struct slapi_filter **filt, char **fstr, int maxdepth, int curdepth,
 	int *subentry_dont_rewrite, int *has_tombstone_filter )
 {
-    unsigned long	len;
+    ber_len_t	len;
     int		err;
     struct slapi_filter	*f;
     char		*ftmp, *type = NULL;
@@ -393,7 +393,8 @@ get_filter_list( Connection *conn, BerElement *ber,
 {
 	struct slapi_filter	**new;
 	int		err;
-	unsigned long	tag, len;
+	ber_tag_t	tag;
+	ber_len_t	len;
 	char		*last;
 
 	LDAPDebug( LDAP_DEBUG_FILTER, "=> get_filter_list\n", 0, 0, 0 );
@@ -440,7 +441,8 @@ get_substring_filter(
     char		**fstr
 )
 {
-	unsigned long	tag, len, rc;
+	ber_tag_t	tag, rc;
+	ber_len_t	len;
 	char		*val, *last, *type = NULL;
 	char		ebuf[BUFSIZ];
 
@@ -543,9 +545,10 @@ static int
 get_extensible_filter( BerElement *ber, mr_filter_t* mrf )
 {
 	int		gotelem, gotoid, gotvalue;
-	unsigned long	tag, len;
+	ber_tag_t	tag;
+	ber_len_t	len;
 	char		*last;
-	int		rc = LDAP_PROTOCOL_ERROR;
+	int		rc = LDAP_SUCCESS;
 
 	LDAPDebug( LDAP_DEBUG_FILTER, "=> get_extensible_filter\n", 0, 0, 0 );
 	memset (mrf, 0, sizeof (mr_filter_t));
@@ -566,7 +569,9 @@ get_extensible_filter( BerElement *ber, mr_filter_t* mrf )
 			if ( gotelem != 0 ) {
 				goto parsing_error;
 			}
-			rc = ber_scanf( ber, "a", &mrf->mrf_oid );
+			if (ber_scanf( ber, "a", &mrf->mrf_oid ) == LBER_ERROR) {
+				rc = LDAP_PROTOCOL_ERROR;
+			}
 			gotoid = 1;
 			gotelem++;
 			break;
@@ -592,7 +597,9 @@ get_extensible_filter( BerElement *ber, mr_filter_t* mrf )
 			if ( gotelem != 1 && gotelem != 2 ) {
 				goto parsing_error;
 			}
-			rc = ber_scanf( ber, "o", &mrf->mrf_value );
+			if (ber_scanf( ber, "o", &mrf->mrf_value ) == LBER_ERROR) {
+				rc = LDAP_PROTOCOL_ERROR;
+			}
 			gotvalue = 1;
 			gotelem++;
 			break;
@@ -600,16 +607,17 @@ get_extensible_filter( BerElement *ber, mr_filter_t* mrf )
 			if ( gotvalue != 1 ) {
 				goto parsing_error;
 			}
-			rc = ber_scanf( ber, "b", &mrf->mrf_dnAttrs );
+			if (ber_scanf( ber, "b", &mrf->mrf_dnAttrs ) == LBER_ERROR) {
+				 rc = LDAP_PROTOCOL_ERROR;
+			}
 			gotelem++;
 			break;
 		default:
 			goto parsing_error;
 		}
-		if ( rc == -1 ) {
+		if ( rc != LDAP_SUCCESS ) {
 			goto parsing_error;
 		}
-		rc = LDAP_SUCCESS;
 	}
 
 	if ( tag == LBER_ERROR ) {

+ 2 - 2
ldap/servers/slapd/libglobs.c

@@ -4103,10 +4103,10 @@ config_set_maxbersize( const char *attrname, char *value, char *errorbuf, int ap
   return retVal;
 }
 
-unsigned long
+ber_len_t
 config_get_maxbersize()
 {
-    unsigned long maxbersize;
+    ber_len_t maxbersize;
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
 
     maxbersize = slapdFrontendConfig->maxbersize;

+ 10 - 9
ldap/servers/slapd/modify.c

@@ -115,14 +115,15 @@ do_modify( Slapi_PBlock *pb )
 	Slapi_Operation *operation;
 	BerElement			*ber;
 	char				*last, *type = NULL;
-	unsigned long		tag, len;
+	ber_tag_t			tag;
+	ber_len_t			len;
 	LDAPMod				*mod;
-	LDAPMod			    **mods;
+	LDAPMod				**mods;
 	Slapi_Mods			smods;
-	int					err;
-	int					pw_change = 0; 	/* 0= no password change */
-	int					ignored_some_mods = 0;
-	int                 has_password_mod = 0; /* number of password mods */
+	int				err;
+	int				pw_change = 0; 	/* 0= no password change */
+	int				ignored_some_mods = 0;
+	int				has_password_mod = 0; /* number of password mods */
 	char				*old_pw = NULL;	/* remember the old password */
 	char				*dn = NULL;
 
@@ -177,11 +178,11 @@ do_modify( Slapi_PBlock *pb )
 	    tag != LBER_ERROR && tag != LBER_END_OF_SEQORSET;
 	    tag = ber_next_element( ber, &len, last ) )
 	{
-		long long_mod_op;
+		ber_int_t mod_op;
 		mod = (LDAPMod *) slapi_ch_malloc( sizeof(LDAPMod) );
 		mod->mod_bvalues = NULL;
 
-		if ( ber_scanf( ber, "{i{a[V]}}", &long_mod_op, &type,
+		if ( ber_scanf( ber, "{i{a[V]}}", &mod_op, &type,
 		    &mod->mod_bvalues ) == LBER_ERROR )
 		{
 			op_shared_log_error_access (pb, "MOD", dn, "decoding error");
@@ -192,7 +193,7 @@ do_modify( Slapi_PBlock *pb )
 			slapi_ch_free_string(&type);
 			goto free_and_return;
 		}
-		mod->mod_op = long_mod_op;
+		mod->mod_op = mod_op;
 		mod->mod_type = slapi_attr_syntax_normalize(type);
 		if ( !mod->mod_type || !*mod->mod_type ) {
 			char ebuf[BUFSIZ];

+ 3 - 3
ldap/servers/slapd/modrdn.c

@@ -67,9 +67,9 @@ do_modrdn( Slapi_PBlock *pb )
 	Slapi_Operation *operation;
 	BerElement	*ber;
 	char		*dn = NULL, *newsuperior = NULL;
-	char        *newrdn = NULL;
-	int			err = 0, deloldrdn = 0;
-	unsigned long	len = 0;
+	char		*newrdn = NULL;
+	int		err = 0, deloldrdn = 0;
+	ber_len_t	len = 0;
 
 	LDAPDebug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
 

+ 4 - 3
ldap/servers/slapd/passwd_extop.c

@@ -240,9 +240,10 @@ passwd_modify_extop( Slapi_PBlock *pb )
 	char		*newPasswd = NULL;
 	char		*errMesg = NULL;
 	int             ret=0, rc=0, sasl_ssf=0;
-	unsigned long	tag=0, len=-1;
-	struct berval *extop_value = NULL;
-	struct berval *gen_passwd = NULL;
+	ber_tag_t	tag=0;
+	ber_len_t	len=-1;
+	struct berval	*extop_value = NULL;
+	struct berval	*gen_passwd = NULL;
 	BerElement	*ber = NULL;
 	BerElement	*response_ber = NULL;
 	Slapi_Entry *targetEntry=NULL;

+ 3 - 3
ldap/servers/slapd/proto-slap.h

@@ -392,7 +392,7 @@ int config_get_auditlog_logging_enabled();
 char *config_get_referral_mode(void);
 int config_get_conntablesize(void);
 int config_check_referral_mode(void);
-unsigned long config_get_maxbersize();
+ber_len_t config_get_maxbersize();
 char *config_get_versionstring();
 char *config_get_buildnum(void);
 int config_get_enquote_sup_oc();
@@ -985,11 +985,11 @@ int modify_root_dse( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *entryAfter,
  */
 void ps_init_psearch_system();
 void ps_stop_psearch_system();
-void ps_add( Slapi_PBlock *pb, int changetypes, int send_entchg_controls );
+void ps_add( Slapi_PBlock *pb, ber_int_t changetypes, int send_entchg_controls );
 void ps_wakeup_all();
 void ps_service_persistent_searches( Slapi_Entry *e, Slapi_Entry *eprev, int chgtype,
 	int chgnum );
-int ps_parse_control_value( struct berval *psbvp, int *changetypesp,
+int ps_parse_control_value( struct berval *psbvp, ber_int_t *changetypesp,
     int *changesonlyp, int *returnecsp );
 
 /*

+ 4 - 6
ldap/servers/slapd/psearch.c

@@ -72,7 +72,7 @@ typedef struct _psearch {
     PSEQNode		*ps_eq_head;
     PSEQNode		*ps_eq_tail;
     time_t		ps_lasttime;
-    int			ps_changetypes;
+    ber_int_t		ps_changetypes;
     int			ps_send_entchg_controls;
     struct _psearch	*ps_next;
 } PSearch;
@@ -175,7 +175,7 @@ ps_stop_psearch_system()
  * are dispatched by add, modify, and modrdn operations.
  */
 void
-ps_add( Slapi_PBlock *pb, int changetypes, int send_entchg_controls )
+ps_add( Slapi_PBlock *pb, ber_int_t changetypes, int send_entchg_controls )
 {
     PSearch	*ps;
 
@@ -658,10 +658,9 @@ ps_service_persistent_searches( Slapi_Entry *e, Slapi_Entry *eprev, int chgtype,
  * the PS subsystem.
  */
 int
-ps_parse_control_value( struct berval *psbvp, int *changetypesp, int *changesonlyp, int *returnecsp )
+ps_parse_control_value( struct berval *psbvp, ber_int_t *changetypesp, int *changesonlyp, int *returnecsp )
 {
     int rc= LDAP_SUCCESS;
-    long long_changetypesp;
 
     if ( psbvp->bv_len == 0 || psbvp->bv_val == NULL )
     {
@@ -676,11 +675,10 @@ ps_parse_control_value( struct berval *psbvp, int *changetypesp, int *changesonl
         }
         else
         {
-            if ( ber_scanf( ber, "{ibb}", &long_changetypesp, changesonlyp, returnecsp ) == LBER_ERROR )
+            if ( ber_scanf( ber, "{ibb}", changetypesp, changesonlyp, returnecsp ) == LBER_ERROR )
             {
             	rc= LDAP_PROTOCOL_ERROR;
             }
-            *changetypesp = (int) long_changetypesp;
         	/* the ber encoding is no longer needed */
         	ber_free(ber,1);
         }

+ 14 - 14
ldap/servers/slapd/result.c

@@ -69,7 +69,7 @@ static int flush_ber( Slapi_PBlock *pb, Connection *conn,
 	Operation *op, BerElement *ber, int type );
 static char *notes2str( unsigned int notes, char *buf, size_t buflen );
 static void log_result( Slapi_PBlock *pb, Operation *op, int err,
-	unsigned long tag, int nentries );
+	ber_tag_t tag, int nentries );
 static void log_entry( Operation *op, Slapi_Entry *e );
 static void log_referral( Operation *op );
 
@@ -229,7 +229,7 @@ send_ldap_result(
 
 
 static int
-check_and_send_extended_result(Slapi_PBlock *pb, unsigned long tag, BerElement *ber)
+check_and_send_extended_result(Slapi_PBlock *pb, ber_tag_t tag, BerElement *ber)
 {
 	/*
 	 * if this is an LDAPv3 ExtendedResponse to an ExtendedRequest,
@@ -257,7 +257,7 @@ check_and_send_extended_result(Slapi_PBlock *pb, unsigned long tag, BerElement *
 }
 
 static int
-check_and_send_SASL_response(Slapi_PBlock *pb, unsigned long tag, BerElement *ber, Connection *conn)
+check_and_send_SASL_response(Slapi_PBlock *pb, ber_tag_t tag, BerElement *ber, Connection *conn)
 {
 	/*
 	 * if this is an LDAPv3 BindResponse, check to see if the
@@ -296,7 +296,7 @@ send_ldap_result_ext(
 {
 	Connection	*conn = pb->pb_conn;
 	int		i, rc, logit = 0;
-	unsigned long	tag;
+	ber_tag_t	tag;
 	int             flush_ber_element = 1;
   	Slapi_Operation *operation;
 	char *dn;
@@ -1421,7 +1421,7 @@ log_and_return:
 	    log_entry( op, e );
 
 	    if (send_result) {
-		unsigned long	tag;
+		ber_tag_t	tag;
 
 		switch ( op->o_tag ) {
 		case LBER_DEFAULT:
@@ -1472,7 +1472,7 @@ flush_ber(
     int		type
 )
 {
-	unsigned long	bytes;
+	ber_len_t	bytes;
 	int		rc = 0;
 
 	switch ( type ) {
@@ -1529,7 +1529,7 @@ flush_ber(
 		} else {
 			PRUint64 b;
 			LDAPDebug( LDAP_DEBUG_BER,
-				"flush_ber() wrote %lu bytes to socket %d\n",
+				"flush_ber() wrote %u bytes to socket %d\n",
 				bytes, conn->c_sd, 0 );
 			LL_I2L ( b, bytes ) ;
 			LL_ADD ( num_bytes_sent, num_bytes_sent, b);
@@ -1647,7 +1647,7 @@ notes2str( unsigned int notes, char *buf, size_t buflen )
 #define ETIME_BUFSIZ 16         /* room for 99999999.999999 */
 
 static void
-log_result( Slapi_PBlock *pb, Operation *op, int err, unsigned long tag,
+log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag,
 	int nentries )
 {
 	char	*notes_str, notes_buf[ 256 ];
@@ -1696,7 +1696,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, unsigned long tag,
 			{
 				slapi_log_access( LDAP_DEBUG_STATS,
 								  "conn=%d op=%d RESULT err=%d"
-								  " tag=%lu nentries=%d etime=%s%s%s"
+								  " tag=%u nentries=%d etime=%s%s%s"
 								  ", SASL bind in progress\n",
 								  op->o_connid, 
 								  op->o_opid,
@@ -1708,7 +1708,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, unsigned long tag,
 			{
 				slapi_log_access( LDAP_DEBUG_ARGS,
 								  "conn=%s op=%d RESULT err=%d"
-								  " tag=%lu nentries=%d etime=%s%s%s"
+								  " tag=%u nentries=%d etime=%s%s%s"
 								  ", SASL bind in progress\n",
 									LOG_INTERNAL_OP_CON_ID,
 									LOG_INTERNAL_OP_OP_ID,
@@ -1728,7 +1728,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, unsigned long tag,
 			{
 				slapi_log_access( LDAP_DEBUG_STATS,
 								  "conn=%d op=%d RESULT err=%d"
-								  " tag=%lu nentries=%d etime=%s%s%s"
+								  " tag=%u nentries=%d etime=%s%s%s"
 								  " dn=\"%s\"\n",
 								  op->o_connid, 
 								  op->o_opid,
@@ -1740,7 +1740,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, unsigned long tag,
 			{
 				slapi_log_access( LDAP_DEBUG_ARGS,
 								  "conn=%s op=%d RESULT err=%d"
-								  " tag=%lu nentries=%d etime=%s%s%s"
+								  " tag=%u nentries=%d etime=%s%s%s"
 								  " dn=\"%s\"\n",
 									LOG_INTERNAL_OP_CON_ID,
 									LOG_INTERNAL_OP_OP_ID,	
@@ -1754,7 +1754,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, unsigned long tag,
 			{
 				slapi_log_access( LDAP_DEBUG_STATS,
 								  "conn=%d op=%d RESULT err=%d"
-								  " tag=%lu nentries=%d etime=%s%s%s\n",
+								  " tag=%u nentries=%d etime=%s%s%s\n",
 								  op->o_connid, 
 								  op->o_opid,
 								  err, tag, nentries, 
@@ -1765,7 +1765,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, unsigned long tag,
 			{
 				slapi_log_access( LDAP_DEBUG_ARGS,
 								  "conn=%s op=%d RESULT err=%d"
-								  " tag=%lu nentries=%d etime=%s%s%s\n",
+								  " tag=%u nentries=%d etime=%s%s%s\n",
 									LOG_INTERNAL_OP_CON_ID,
 									LOG_INTERNAL_OP_OP_ID,
 								  err, tag, nentries, 

+ 4 - 10
ldap/servers/slapd/search.c

@@ -61,16 +61,14 @@ do_search( Slapi_PBlock *pb )
 {
 	Slapi_Operation *operation;
     BerElement	*ber;
-    int			i, err;
-    int			scope, deref, attrsonly;
-    int			sizelimit, timelimit;
-    long		long_scope,long_deref,long_sizelimit,long_timelimit;
+    int			i, err, attrsonly;
+    ber_int_t		scope, deref, sizelimit, timelimit;
     char		*base = NULL, *fstr = NULL;
     struct slapi_filter	*filter = NULL;
     char		**attrs = NULL;
     int			psearch = 0;
     struct berval	*psbvp;
-	int			changetypes;
+    ber_int_t		changetypes;
 	int			send_entchg_controls;
 	int			changesonly = 0;
 	int			rc = -1;
@@ -110,16 +108,12 @@ do_search( Slapi_PBlock *pb )
      */
 
     /* baseObject, scope, derefAliases, sizelimit, timelimit, attrsOnly */
-    if ( ber_scanf( ber, "{aiiiib", &base, &long_scope, &long_deref, &long_sizelimit, &long_timelimit, &attrsonly ) == LBER_ERROR ){
+    if ( ber_scanf( ber, "{aiiiib", &base, &scope, &deref, &sizelimit, &timelimit, &attrsonly ) == LBER_ERROR ){
         slapi_ch_free((void**)&base );
         log_search_access (pb, "???", -1, "???", "decoding error");
         send_ldap_result( pb, LDAP_PROTOCOL_ERROR, NULL, NULL, 0, NULL );
         return;
     }
-    scope = long_scope;
-    deref = long_deref;
-    sizelimit = long_sizelimit;
-    timelimit = long_timelimit;
 
     /*
      * ignore negative time and size limits since they make no sense

+ 3 - 3
ldap/servers/slapd/slap.h

@@ -1160,8 +1160,8 @@ typedef struct slapi_operation_results
  */
 typedef struct op {
 	BerElement	*o_ber;		/* ber of the request		  */
-	long		o_msgid;	/* msgid of the request		  */
-	unsigned long	o_tag;		/* tag of the request		  */
+	ber_int_t	o_msgid;	/* msgid of the request		  */
+	ber_tag_t	o_tag;		/* tag of the request		  */
 	time_t		o_time;		/* time op was initiated	  */
 	PRIntervalTime	o_interval;	/* precise time op was initiated  */
 	int		o_isroot;	/* requestor is manager		  */
@@ -1873,7 +1873,7 @@ typedef struct _slapdFrontendConfig {
   int refer_mode;       /* for quick test */
   int	slapd_type;		/* Directory type; Full or Lite */
   
-  unsigned long maxbersize; /* Maximum BER element size we'll accept */
+  ber_len_t maxbersize; /* Maximum BER element size we'll accept */
   int max_filter_nest_level;/* deepest nested filter we will accept */
   int enquote_sup_oc;  /* put single quotes around an oc's 
 						  superior oc in cn=schema */

+ 1 - 1
ldap/servers/slapd/tools/rsearch/searchthread.c

@@ -259,7 +259,7 @@ static int st_bind(SearchThread *st)
         l.l_linger = 0;
         if (setsockopt(st->soc, SOL_SOCKET, SO_LINGER, (char *)&l, val) < 0) {
             fprintf(stderr, "T%d: failed in setsockopt 2, errno %d (%d)\n",
-                    st->id, errno, st->soc);
+                    st->id, errno, (int)st->soc);
             st->soc = -1;
             return 0;
         }