CVS: sylpheedclaws/sylpheed-claws/src ldapquery.c,1.3.2.9,1.3.2.10 ldaputil.c,1.1.4.4,1.1.4.5 syldap.c,1.16.2.5,NONE syldap.h,1.9.2.3,NONE

[email protected] Wed, 13 Dec 2006 20:53:32 +0000
Newsgroups gmane.mail.sylpheed.claws.cvs
Message-ID <[email protected]>
Update of /pack/anoncvs/sylpheedclaws/sylpheed-claws/src
In directory sunsite.dk:/tmp/cvs-serv7744/src

Modified Files:
      Tag: gtk2
	ldapquery.c ldaputil.c 
Removed Files:
      Tag: gtk2
	syldap.c syldap.h 
Log Message:
2006-12-13 [colin]	2.6.1cvs30

	* src/ldapquery.c
	* src/ldaputil.c
		Use the binary safe version of ldap_get_values,
		to make sure we manipulate null-terminated 
		strings. Maybe fixes bug 1075, 'claws mail 
		segfault when completing ldap adresses'
	* src/syldap.c ** REMOVED **
	* src/syldap.h ** REMOVED **
		Remove dead files

Index: ldapquery.c
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/ldapquery.c,v
retrieving revision 1.3.2.9
retrieving revision 1.3.2.10
diff -u -d -r1.3.2.9 -r1.3.2.10
--- ldapquery.c	2006/11/07 10:39:00	1.3.2.9
+++ ldapquery.c	2006/12/13 20:53:22	1.3.2.10
@@ -461,15 +461,15 @@
 {
 	GSList *list = NULL;
 	gint i;
-	gchar **vals;
+	struct berval **vals;
 
-	if( ( vals = ldap_get_values( ld, entry, attr ) ) != NULL ) {
+	if( ( vals = ldap_get_values_len( ld, entry, attr ) ) != NULL ) {
 		for( i = 0; vals[i] != NULL; i++ ) {
 			/* printf( "lv\t%s: %s\n", attr, vals[i] ); */
-			list = g_slist_append( list, g_strdup( vals[i] ) );
+			list = g_slist_append( list, g_strndup( vals[i]->bv_val, vals[i]->bv_len) );
 		}
 	}
-	ldap_value_free( vals );
+	ldap_value_free_len( vals );
 	return list;
 }
 
@@ -482,15 +482,15 @@
  */
 static GSList *ldapqry_add_single_value( LDAP *ld, LDAPMessage *entry, char *attr ) {
 	GSList *list = NULL;
-	gchar **vals;
+	struct berval **vals;
 
-	if( ( vals = ldap_get_values( ld, entry, attr ) ) != NULL ) {
+	if( ( vals = ldap_get_values_len( ld, entry, attr ) ) != NULL ) {
 		if( vals[0] != NULL ) {
 			/* printf( "sv\t%s: %s\n", attr, vals[0] ); */
-			list = g_slist_append( list, g_strdup( vals[0] ) );
+			list = g_slist_append( list, g_strndup( vals[0]->bv_val, vals[0]->bv_len ));
 		}
 	}
-	ldap_value_free( vals );
+	ldap_value_free_len( vals );
 	return list;
 }
 
@@ -1212,17 +1212,19 @@
 {
 	GList *list = NULL;
 	gint i;
-	gchar **vals;
+	struct berval **vals;
 	NameValuePair *nvp;
 
 	list = listValues;
-	if( ( vals = ldap_get_values( ld, entry, attr ) ) != NULL ) {
+	if( ( vals = ldap_get_values_len( ld, entry, attr ) ) != NULL ) {
 		for( i = 0; vals[i] != NULL; i++ ) {
-			nvp = ldapqry_create_name_value( attr, vals[i] );
+			gchar *tmp = g_strndup( vals[i]->bv_val, vals[i]->bv_len);
+			nvp = ldapqry_create_name_value( attr, tmp );
+			g_free(tmp);
 			list = g_list_append( list, nvp );
 		}
 	}
-	ldap_value_free( vals );
+	ldap_value_free_len( vals );
 	return list;
 }
 

Index: ldaputil.c
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/ldaputil.c,v
retrieving revision 1.1.4.4
retrieving revision 1.1.4.5
diff -u -d -r1.1.4.4 -r1.1.4.5
--- ldaputil.c	2006/11/07 10:39:01	1.1.4.4
+++ ldaputil.c	2006/12/13 20:53:22	1.1.4.5
@@ -54,7 +54,7 @@
 	gchar *attribs[2];
 	BerElement *ber;
 	gchar *attribute;
-	gchar **vals;
+	struct berval **vals;
 	struct timeval timeout;
 
 	/* Set timeout */
@@ -87,14 +87,14 @@
 				if( strcasecmp(
 					attribute, SYLDAP_V3_TEST_ATTR ) == 0 )
 				{
-					vals = ldap_get_values( ld, e, attribute );
+					vals = ldap_get_values_len( ld, e, attribute );
 					if( vals != NULL ) {
 						for( i = 0; vals[i] != NULL; i++ ) {
 							baseDN = g_list_append(
-								baseDN, g_strdup( vals[i] ) );
+								baseDN, g_strndup( vals[i]->bv_val, vals[i]->bv_len ) );
 						}
 					}
-					ldap_value_free( vals );
+					ldap_value_free_len( vals );
 				}
 				ldap_memfree( attribute );
 			}
@@ -125,7 +125,7 @@
 	gchar *attribs[1];
 	BerElement *ber;
 	gchar *attribute;
-	gchar **vals;
+	struct berval **vals;
 	struct timeval timeout;
 
 	/* Set timeout */
@@ -156,15 +156,16 @@
 				if( strcasecmp(
 					attribute,
 					SYLDAP_V2_TEST_ATTR ) == 0 ) {
-					vals = ldap_get_values( ld, e, attribute );
+					vals = ldap_get_values_len( ld, e, attribute );
 					if( vals != NULL ) {
 						for( i = 0; vals[i] != NULL; i++ ) {
-							char *ch;
+							char *ch, *tmp;
 							/*
 							 * Strip the 'ldb:' from the
 							 * front of the value.
 							 */
-							ch = ( char * ) strchr( vals[i], ':' );
+							tmp = g_strndup( vals[i]->bv_val, vals[i]->bv_len);
+							ch = ( char * ) strchr( tmp, ':' );
 							if( ch ) {
 								gchar *bn = g_strdup( ++ch );
 								g_strchomp( bn );
@@ -173,9 +174,10 @@
 									baseDN, g_strdup( bn ) );
 								g_free( bn );
 							}
+							g_free(tmp);
 						}
 					}
-					ldap_value_free( vals );
+					ldap_value_free_len( vals );
 				}
 				ldap_memfree( attribute );
 			}

--- syldap.c DELETED ---

--- syldap.h DELETED ---