X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Flimits.c;h=cf22aed463252dbad93f1bf41a5822f42c053b8f;hb=3bbaa8103b351f3268b08f8a276ea49ac7067b47;hp=740eeb449c2f82adc2a820066669a5fec4d7e001;hpb=0f22e6bb04031059e18d8956da2e80c9351dd164;p=openldap
diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c
index 740eeb449c..cf22aed463 100644
--- a/servers/slapd/limits.c
+++ b/servers/slapd/limits.c
@@ -2,7 +2,7 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 1998-2008 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -18,6 +18,7 @@
#include
+#include
#include
#include
@@ -248,7 +249,6 @@ limits_add(
case SLAP_LIMITS_ONE:
case SLAP_LIMITS_SUBTREE:
case SLAP_LIMITS_CHILDREN:
- lm->lm_flags = style | type;
{
int rc;
struct berval bv;
@@ -264,7 +264,6 @@ limits_add(
break;
case SLAP_LIMITS_REGEX:
- lm->lm_flags = style | type;
ber_str2bv( pattern, 0, 1, &lm->lm_pat );
if ( regcomp( &lm->lm_regex, lm->lm_pat.bv_val,
REG_EXTENDED | REG_ICASE ) ) {
@@ -277,7 +276,6 @@ limits_add(
case SLAP_LIMITS_ANONYMOUS:
case SLAP_LIMITS_USERS:
case SLAP_LIMITS_ANY:
- lm->lm_flags = style | type;
BER_BVZERO( &lm->lm_pat );
break;
}
@@ -291,6 +289,7 @@ limits_add(
break;
}
+ lm->lm_flags = style | type;
lm->lm_limits = *limit;
i = 0;
@@ -447,6 +446,11 @@ limits_parse(
{
flags = SLAP_LIMITS_ANONYMOUS;
pattern = NULL;
+
+ } else {
+ /* force error below */
+ if ( *pattern == '=' )
+ --pattern;
}
}
@@ -454,13 +458,14 @@ limits_parse(
if ( pattern != NULL ) {
if ( pattern[0] != '=' ) {
Debug( LDAP_DEBUG_ANY,
- "%s : line %d: missing '=' in "
+ "%s : line %d: %s in "
"\"dn[.{this|self}][.{exact|base"
- "|onelevel|subtree|children|regex}]"
- "=\" in "
- "\"limits \" "
- "line.\n%s",
- fname, lineno, "" );
+ "|onelevel|subtree|children|regex"
+ "|anonymous}]=\" in "
+ "\"limits \" line.\n",
+ fname, lineno,
+ isalnum( (unsigned char)pattern[0] )
+ ? "unknown DN modifier" : "missing '='" );
return( -1 );
}
@@ -1319,6 +1324,19 @@ limits_check( Operation *op, SlapReply *rs )
return 0;
}
+void
+limits_free_one(
+ struct slap_limits *lm )
+{
+ if ( ( lm->lm_flags & SLAP_LIMITS_MASK ) == SLAP_LIMITS_REGEX )
+ regfree( &lm->lm_regex );
+
+ if ( !BER_BVISNULL( &lm->lm_pat ) )
+ ch_free( lm->lm_pat.bv_val );
+
+ ch_free( lm );
+}
+
void
limits_destroy(
struct slap_limits **lm )
@@ -1330,25 +1348,7 @@ limits_destroy(
}
for ( i = 0; lm[ i ]; i++ ) {
- switch ( lm[ i ]->lm_flags & SLAP_LIMITS_MASK ) {
- case SLAP_LIMITS_REGEX:
- regfree( &lm[ i ]->lm_regex );
- break;
-
- case SLAP_LIMITS_EXACT:
- case SLAP_LIMITS_ONE:
- case SLAP_LIMITS_SUBTREE:
- case SLAP_LIMITS_CHILDREN:
- if ( !BER_BVISNULL( &lm[ i ]->lm_pat ) ) {
- ch_free( lm[ i ]->lm_pat.bv_val );
- }
- break;
-
- default:
- break;
- }
-
- ch_free( lm[ i ] );
+ limits_free_one( lm[ i ] );
}
ch_free( lm );