[Fedora-directory-commits] ldapserver/ldap/servers/slapd entry.c, 1.14, 1.14.2.1 filterentry.c, 1.6.2.1, 1.6.2.2 getfilelist.c, 1.7, 1.7.2.1 plugin_syntax.c, 1.5, 1.5.2.1 proto-slap.h, 1.31, 1.31.2.1 regex.c, 1.5.2.1, 1.5.2.2 sasl_map.c, 1.8, 1.8.2.1 slapi-private.h, 1.20, 1.20.2.1 vattr.c, 1.8, 1.8.2.1

Nathan Kinder (nkinder) fedora-directory-commits at redhat.com
Fri Jul 11 17:18:45 UTC 2008


Author: nkinder

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8956/servers/slapd

Modified Files:
      Tag: Directory_Server_8_0_Branch
	entry.c filterentry.c getfilelist.c plugin_syntax.c 
	proto-slap.h regex.c sasl_map.c slapi-private.h vattr.c 
Log Message:
Resolves: 448831
Summary: Make regex code obey search timelimit.



Index: entry.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/entry.c,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- entry.c	18 Oct 2007 00:08:34 -0000	1.14
+++ entry.c	11 Jul 2008 17:18:43 -0000	1.14.2.1
@@ -1836,7 +1836,7 @@
 														f->f_choice,
 														&f->f_ava );
 				} else if ( filter_type == FILTER_TYPE_SUBSTRING) {
-					*rc = plugin_call_syntax_filter_sub( tmp_attr,
+					*rc = plugin_call_syntax_filter_sub( NULL, tmp_attr,
 															&f->f_sub);
 				} else if ( filter_type == FILTER_TYPE_PRES ) {
 					/* type is there, that's all we need to know. */


Index: filterentry.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/filterentry.c,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -r1.6.2.1 -r1.6.2.2
--- filterentry.c	18 Apr 2008 20:18:59 -0000	1.6.2.1
+++ filterentry.c	11 Jul 2008 17:18:43 -0000	1.6.2.2
@@ -693,7 +693,7 @@
 			rc = -1;
 			for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
 				if ( slapi_attr_type_cmp( f->f_sub_type, a->a_type, SLAPI_TYPE_CMP_SUBTYPE ) == 0 ) {
-					rc = plugin_call_syntax_filter_sub( a, &f->f_sub );
+					rc = plugin_call_syntax_filter_sub( pb, a, &f->f_sub );
 					if ( rc == 0 ) {
 						break;
 					}
@@ -726,8 +726,8 @@
 		rc = -1;
 		for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
 			if ( slapi_attr_type_cmp( f->f_sub_type, a->a_type, SLAPI_TYPE_CMP_SUBTYPE ) == 0 ) {
-				rc = plugin_call_syntax_filter_sub( a, &f->f_sub );
-				if ( rc == 0 ) {
+				rc = plugin_call_syntax_filter_sub( pb, a, &f->f_sub );
+				if ( rc == 0 || rc == LDAP_TIMELIMIT_EXCEEDED ) {
 					break;
 				}
 			}


Index: getfilelist.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/getfilelist.c,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- getfilelist.c	10 Nov 2006 23:45:40 -0000	1.7
+++ getfilelist.c	11 Jul 2008 17:18:43 -0000	1.7.2.1
@@ -130,7 +130,7 @@
 	slapd_re_lock();
 	s = slapd_re_comp((char *)pattern);
 	if (!s)
-		match = slapd_re_exec((char *)filename);
+		match = slapd_re_exec((char *)filename, -1 /* no timelimit */);
 	slapd_re_unlock();
 
 	return match;


Index: plugin_syntax.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/plugin_syntax.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- plugin_syntax.c	10 Nov 2006 23:45:40 -0000	1.5
+++ plugin_syntax.c	11 Jul 2008 17:18:43 -0000	1.5.2.1
@@ -211,15 +211,17 @@
 
 int
 plugin_call_syntax_filter_sub(
+    Slapi_PBlock        *pb,
     Slapi_Attr		*a,
     struct subfilt	*fsub
 )
 {
-	return(plugin_call_syntax_filter_sub_sv(a,fsub));
+	return(plugin_call_syntax_filter_sub_sv(pb,a,fsub));
 }
 
 int
 plugin_call_syntax_filter_sub_sv(
+    Slapi_PBlock        *pb,
     Slapi_Attr		*a,
     struct subfilt	*fsub
 )
@@ -240,6 +242,13 @@
 	{
 		Slapi_Value **va= valueset_get_valuearray(&a->a_present_values);
 		pblock_init( &pipb );
+		if (pb)
+		{
+			Operation *op = NULL;
+			/* to pass SLAPI_SEARCH_TIMELIMIT & SLAPI_OPINITATED_TIME */
+			slapi_pblock_get( pb, SLAPI_OPERATION, &op );
+			slapi_pblock_set( &pipb, SLAPI_OPERATION, op );
+		}
 		slapi_pblock_set( &pipb, SLAPI_PLUGIN, (void *) a->a_plugin );
 		rc = a->a_plugin->plg_syntax_filter_sub( &pipb,
 		    fsub->sf_initial, fsub->sf_any, fsub->sf_final, va);


Index: proto-slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/proto-slap.h,v
retrieving revision 1.31
retrieving revision 1.31.2.1
diff -u -r1.31 -r1.31.2.1
--- proto-slap.h	18 Oct 2007 01:22:29 -0000	1.31
+++ proto-slap.h	11 Jul 2008 17:18:43 -0000	1.31.2.1
@@ -740,8 +740,8 @@
 struct slapdplugin *slapi_get_global_syntax_plugins();
 int plugin_call_syntax_filter_ava( const Slapi_Attr *a, int ftype, struct ava *ava );
 int plugin_call_syntax_filter_ava_sv( const Slapi_Attr *a, int ftype, struct ava *ava, Slapi_Value **retVal, int useDeletedValues );
-int plugin_call_syntax_filter_sub( Slapi_Attr *a, struct subfilt *fsub );
-int plugin_call_syntax_filter_sub_sv( Slapi_Attr *a, struct subfilt *fsub );
+int plugin_call_syntax_filter_sub( Slapi_PBlock *pb, Slapi_Attr *a, struct subfilt *fsub );
+int plugin_call_syntax_filter_sub_sv( Slapi_PBlock *pb, Slapi_Attr *a, struct subfilt *fsub );
 int plugin_call_syntax_get_compare_fn(void *vpi, value_compare_fn_type *compare_fn);
 struct slapdplugin *plugin_syntax_find( const char *nameoroid );
 void plugin_syntax_enumerate( SyntaxEnumFunc sef, void *arg );


Index: regex.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/regex.c,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -r1.5.2.1 -r1.5.2.2
--- regex.c	29 Apr 2008 00:38:00 -0000	1.5.2.1
+++ regex.c	11 Jul 2008 17:18:43 -0000	1.5.2.2
@@ -66,6 +66,10 @@
  * Modification history:
  *
  * $Log$
+ * Revision 1.5.2.2  2008/07/11 17:18:43  nkinder
+ * Resolves: 448831
+ * Summary: Make regex code obey search timelimit.
+ *
  * Revision 1.5.2.1  2008/04/29 00:38:00  nhosoi
  * Resolves: #182621 (#443955)
  * Summary: Allow larger regex buffer to enable long substring filters
@@ -699,7 +703,7 @@
 static UCHAR *bopat[MAXTAG];
 static UCHAR *eopat[MAXTAG];
 #ifdef NEEDPROTOS
-static UCHAR *pmatch( UCHAR *lp, UCHAR *ap );
+static UCHAR *pmatch( UCHAR *lp, UCHAR *ap, time_t time_up, int *err );
 #else /* NEEDPROTOS */
 static UCHAR *pmatch();
 #endif /* NEEDPROTOS */
@@ -724,14 +728,18 @@
  *	to the beginning and the end of the matched fragment,
  *	respectively.
  *
+ *   return values: 0 -- did not match
+ *                  1 -- matched
+ *                  othersise -- ldap error (TIMELIMIT_EXCEEDED only)
  */
 
 int
-slapd_re_exec( char *lp )
+slapd_re_exec( char *lp, time_t time_up )
 {
 	register UCHAR c;
 	register UCHAR *ep = 0;
 	register UCHAR *ap = nfa;
+	int ldaperror = 0;
 
 	bol = (UCHAR*)lp;
 
@@ -749,7 +757,7 @@
 	switch(*ap) {
 
 	case BOL:			/* anchored: match from BOL only */
-		ep = pmatch((UCHAR*)lp,ap);
+		ep = pmatch((UCHAR*)lp,ap,time_up,&ldaperror);
 		break;
 	case CHR:			/* ordinary char: locate it fast */
 		c = *(ap+1);
@@ -759,7 +767,7 @@
 			return 0;
 	default:			/* regular matching all the way. */
 		do {
-			if ((ep = pmatch((UCHAR*)lp,ap)))
+			if ((ep = pmatch((UCHAR*)lp,ap,time_up,&ldaperror)))
 				break;
 			lp++;
 		} while (*lp);
@@ -768,6 +776,8 @@
 	case END:			/* munged automaton. fail always */
 		return 0;
 	}
+	if (ldaperror)
+		return ldaperror;
 	if (!ep)
 		return 0;
 
@@ -848,13 +858,19 @@
 #define CCLSKIP 18	/* [CLO] CCL 16bytes END ... */
 
 static UCHAR *
-pmatch( UCHAR *lp, UCHAR *ap)
+pmatch( UCHAR *lp, UCHAR *ap, time_t time_up, int *err )
 {
 	register int op, c, n;
 	register UCHAR *e;		/* extra pointer for CLO */
 	register UCHAR *bp;		/* beginning of subpat.. */
 	register UCHAR *ep;		/* ending of subpat..	 */
 	UCHAR *are;			/* to save the line ptr. */
+	time_t curtime = current_time();
+
+	if ( time_up != -1 && curtime > time_up ) {
+		*err = LDAP_TIMELIMIT_EXCEEDED;
+		return 0;
+	}
 
 	while ((op = *ap++) != END)
 		switch(op) {
@@ -931,7 +947,7 @@
 			ap += n;
 
 			while (lp >= are) {
-				if ((e = pmatch(lp, ap)) != NULL)
+				if ((e = pmatch(lp, ap, time_up, err)) != NULL)
 					return e;
 				--lp;
 			}


Index: sasl_map.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/sasl_map.c,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- sasl_map.c	10 Nov 2006 23:45:40 -0000	1.8
+++ sasl_map.c	11 Jul 2008 17:18:43 -0000	1.8.2.1
@@ -434,9 +434,10 @@
 	recomp_result = slapd_re_comp(dp->regular_expression);
 	if (recomp_result) {
 		LDAPDebug( LDAP_DEBUG_ANY, "sasl_map_check : re_comp failed for expression (%s)\n", dp->regular_expression, 0, 0 );
+	} else {
+		matched = slapd_re_exec(sasl_user_and_realm, -1 /* no timelimit */);
+		LDAPDebug( LDAP_DEBUG_TRACE, "regex: %s, id: %s, %s\n", dp->regular_expression, sasl_user_and_realm, matched ? "matched" : "didn't match" );
 	}
-	matched = slapd_re_exec(sasl_user_and_realm);
-	LDAPDebug( LDAP_DEBUG_TRACE, "regex: %s, id: %s, %s\n", dp->regular_expression, sasl_user_and_realm, matched ? "matched" : "didn't match" );
 	if (matched) {
 		if (matched == 1) {
 			/* Allocate buffers for the returned strings */


Index: slapi-private.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-private.h,v
retrieving revision 1.20
retrieving revision 1.20.2.1
diff -u -r1.20 -r1.20.2.1
--- slapi-private.h	18 Oct 2007 22:40:18 -0000	1.20
+++ slapi-private.h	11 Jul 2008 17:18:43 -0000	1.20.2.1
@@ -1184,7 +1184,7 @@
 
 void bervalarray_add_berval_fast(struct berval ***vals, const struct berval *addval, int nvals, int *maxvals);
 
-int slapd_re_exec( char *lp );
+int slapd_re_exec( char *lp, time_t time_up );
 char *slapd_re_comp( char *pat );
 int slapd_re_subs( char *src, char* dst );
 void slapd_re_lock( void );


Index: vattr.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/vattr.c,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- vattr.c	1 Nov 2007 20:24:07 -0000	1.8
+++ vattr.c	11 Jul 2008 17:18:43 -0000	1.8.2.1
@@ -540,7 +540,7 @@
 									rc = plugin_call_syntax_filter_ava( a,
 															f->f_choice, &f->f_ava );
 								} else if ( filter_type == FILTER_TYPE_SUBSTRING) {
-									rc = plugin_call_syntax_filter_sub( a,
+									rc = plugin_call_syntax_filter_sub( pb, a,
 																		&f->f_sub);
 								}
 
@@ -611,7 +611,7 @@
 								    		
     	} else if ( filter_type == FILTER_TYPE_SUBSTRING ) {
 			
-			rc = test_substring_filter( NULL, e, f, 0 /* no access check */,
+			rc = test_substring_filter( pb, e, f, 0 /* no access check */,
 									0 /* do test filter */, &acl_test_done);
 				
 		} else if ( filter_type == FILTER_TYPE_PRES ) {




More information about the Fedora-directory-commits mailing list