$NetBSD: patch-am,v 1.5 2006/05/15 19:01:23 ghen Exp $

--- libraries/libldap/cyrus.c.orig	2006-05-13 11:47:50.000000000 +0200
+++ libraries/libldap/cyrus.c
@@ -884,7 +884,7 @@ ldap_int_sasl_external(
 	LDAP *ld,
 	LDAPConn *conn,
 	const char * authid,
-	ber_len_t ssf )
+	ber_uint_t ssf )
 {
 	int sc;
 	sasl_conn_t *ctx;
@@ -1026,6 +1026,7 @@ int ldap_pvt_sasl_secprops(
 	char **props;
 	unsigned sflags = 0;
 	int got_sflags = 0;
+	int tmp_ssf;
 	sasl_ssf_t max_ssf = 0;
 	int got_max_ssf = 0;
 	sasl_ssf_t min_ssf = 0;
@@ -1056,9 +1057,9 @@ int ldap_pvt_sasl_secprops(
 				if ( next == &props[i][sprops[j].key.bv_len] || next[0] != '\0' ) continue;
 				switch( sprops[j].ival ) {
 				case GOT_MINSSF:
-					min_ssf = v; got_min_ssf++; break;
+					min_ssf = (v >= 0 ? (sasl_ssf_t)v : 0); got_min_ssf++; break;
 				case GOT_MAXSSF:
-					max_ssf = v; got_max_ssf++; break;
+					max_ssf = (v >= 0 ? (sasl_ssf_t)v : 0); got_max_ssf++; break;
 				case GOT_MAXBUF:
 					maxbufsize = v; got_maxbufsize++; break;
 				}
@@ -1155,7 +1156,7 @@ ldap_int_sasl_get_option( LDAP *ld, int 
 				return -1;
 			}
 
-			*(ber_len_t *)arg = *ssf;
+			*(sasl_ssf_t *)arg = *ssf;
 		} break;
 
 		case LDAP_OPT_X_SASL_SSF_EXTERNAL:
@@ -1163,13 +1164,13 @@ ldap_int_sasl_get_option( LDAP *ld, int 
 			return -1;
 
 		case LDAP_OPT_X_SASL_SSF_MIN:
-			*(ber_len_t *)arg = ld->ld_options.ldo_sasl_secprops.min_ssf;
+			*(sasl_ssf_t *)arg = ld->ld_options.ldo_sasl_secprops.min_ssf;
 			break;
 		case LDAP_OPT_X_SASL_SSF_MAX:
-			*(ber_len_t *)arg = ld->ld_options.ldo_sasl_secprops.max_ssf;
+			*(sasl_ssf_t *)arg = ld->ld_options.ldo_sasl_secprops.max_ssf;
 			break;
 		case LDAP_OPT_X_SASL_MAXBUFSIZE:
-			*(ber_len_t *)arg = ld->ld_options.ldo_sasl_secprops.maxbufsize;
+			*(ber_uint_t *)arg = ld->ld_options.ldo_sasl_secprops.maxbufsize;
 			break;
 
 		case LDAP_OPT_X_SASL_SECPROPS:
@@ -1215,7 +1216,7 @@ ldap_int_sasl_set_option( LDAP *ld, int 
 #else
 		memset(&extprops, 0L, sizeof(extprops));
 
-		extprops.ssf = * (ber_len_t *) arg;
+		extprops.ssf = * (sasl_ssf_t *) arg;
 
 		sc = sasl_setprop( ctx, SASL_SSF_EXTERNAL,
 			(void *) &extprops );
@@ -1227,13 +1228,13 @@ ldap_int_sasl_set_option( LDAP *ld, int 
 		} break;
 
 	case LDAP_OPT_X_SASL_SSF_MIN:
-		ld->ld_options.ldo_sasl_secprops.min_ssf = *(ber_len_t *)arg;
+		ld->ld_options.ldo_sasl_secprops.min_ssf = *(sasl_ssf_t *)arg;
 		break;
 	case LDAP_OPT_X_SASL_SSF_MAX:
-		ld->ld_options.ldo_sasl_secprops.max_ssf = *(ber_len_t *)arg;
+		ld->ld_options.ldo_sasl_secprops.max_ssf = *(sasl_ssf_t *)arg;
 		break;
 	case LDAP_OPT_X_SASL_MAXBUFSIZE:
-		ld->ld_options.ldo_sasl_secprops.maxbufsize = *(ber_len_t *)arg;
+		ld->ld_options.ldo_sasl_secprops.maxbufsize = *(ber_uint_t *)arg;
 		break;
 
 	case LDAP_OPT_X_SASL_SECPROPS: {
@@ -1332,7 +1333,7 @@ ldap_int_sasl_external(
 	LDAP *ld,
 	LDAPConn *conn,
 	const char * authid,
-	ber_len_t ssf )
+	ber_uint_t ssf )
 { return LDAP_SUCCESS; }
 
 #endif /* HAVE_CYRUS_SASL */
