Browse Source

389 DS segfaults on libsyntax-plugin.so - part 1

https://bugzilla.redhat.com/show_bug.cgi?id=516611
Resolves: bug 516611
Bug Description: 389 DS segfaults on libsyntax-plugin.so - part 1
Reviewed by: nkinder (Thanks!)
Branch: HEAD
Fix Description: Check for NULL bvals in the string syntax filter functions
ava, sub, and key generation
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
Rich Megginson 15 years ago
parent
commit
ea0cdc6ce1
1 changed files with 3 additions and 3 deletions
  1. 3 3
      ldap/servers/plugins/syntaxes/string.c

+ 3 - 3
ldap/servers/plugins/syntaxes/string.c

@@ -77,7 +77,7 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
 	value_normalize( bvfilter_norm.bv_val, syntax, 1 /* trim leading blanks */ );
 	bvfilter_norm.bv_len = strlen(bvfilter_norm.bv_val);
 
-	for ( i = 0; bvals[i] != NULL; i++ ) {
+	for ( i = 0; (bvals != NULL) && (bvals[i] != NULL); i++ ) {
 		rc = value_cmp( (struct berval*)slapi_value_get_berval(bvals[i]), &bvfilter_norm, syntax, 1/* Normalise the first value only */ );
                 switch ( ftype ) {
                 case LDAP_FILTER_GE:
@@ -135,7 +135,7 @@ string_filter_approx( struct berval *bvfilter, Slapi_Value **bvals,
 	if(retVal) {
 		*retVal = NULL;
 	}
-	for ( i = 0; bvals[i] != NULL; i++ ) {
+	for ( i = 0; (bvals != NULL) && (bvals[i] != NULL); i++ ) {
 		w2 = (char*)slapi_value_get_string(bvals[i]); /* JCM cast */
 		ava_wordcount = 0;
 		/* for each word in the filter value */
@@ -310,7 +310,7 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final,
 	rc = -1;
 	tmpbuf = NULL;
 	tmpbufsize = 0;
-	for ( j = 0; bvals[j] != NULL; j++ ) {
+	for ( j = 0; (bvals != NULL) && (bvals[j] != NULL); j++ ) {
 		int	tmprc;
 		size_t	len;
 		const struct berval *bvp = slapi_value_get_berval(bvals[j]);