mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-11-21 01:04:44 +08:00
Add NAME check
This commit is contained in:
parent
5550e224de
commit
ca8185c296
@ -239,11 +239,19 @@ at_add(
|
||||
char *cname;
|
||||
|
||||
if ( at->at_names && at->at_names[0] ) {
|
||||
int i;
|
||||
|
||||
for( i=0; at->at_names[i]; i++ ) {
|
||||
if( !slap_valid_descr( at->at_names[i] ) ) {
|
||||
return SLAP_SCHERR_BAD_DESCR;
|
||||
}
|
||||
}
|
||||
|
||||
cname = at->at_names[0];
|
||||
|
||||
} else if ( at->at_oid ) {
|
||||
cname = at->at_oid;
|
||||
} else {
|
||||
cname = "";
|
||||
return SLAP_SCHERR_ATTR_INCOMPLETE;
|
||||
}
|
||||
|
||||
|
@ -350,6 +350,16 @@ oc_add(
|
||||
ObjectClass *soc;
|
||||
int code;
|
||||
|
||||
if ( oc->oc_names != NULL ) {
|
||||
int i;
|
||||
|
||||
for( i=0; oc->oc_names[i]; i++ ) {
|
||||
if( !slap_valid_descr( oc->oc_names[i] ) ) {
|
||||
return SLAP_SCHERR_BAD_DESCR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
soc = (ObjectClass *) ch_calloc( 1, sizeof(ObjectClass) );
|
||||
AC_MEMCPY( &soc->soc_oclass, oc, sizeof(LDAPObjectClass) );
|
||||
|
||||
|
@ -13,6 +13,8 @@ LDAP_BEGIN_DECL
|
||||
LDAP_SLAPD_F( int ) schema_init_done;
|
||||
LDAP_SLAPD_F( struct slap_internal_schema ) slap_schema;
|
||||
|
||||
LDAP_SLAPD_F( int ) slap_valid_descr( const char * );
|
||||
|
||||
LDAP_SLAPD_F (int) slap_str2ad LDAP_P((
|
||||
const char *,
|
||||
AttributeDescription **ad,
|
||||
|
@ -37,7 +37,8 @@ static char *const err2text[] = {
|
||||
"MatchingRule not found",
|
||||
"Syntax not found",
|
||||
"Syntax required",
|
||||
"Qualifier not supported"
|
||||
"Qualifier not supported",
|
||||
"Invalid NAME"
|
||||
};
|
||||
|
||||
char *
|
||||
@ -50,6 +51,24 @@ scherr2str(int code)
|
||||
}
|
||||
}
|
||||
|
||||
/* check schema descr validity */
|
||||
int slap_valid_descr( const char *descr )
|
||||
{
|
||||
int i=0;
|
||||
|
||||
if( !DESC_LEADCHAR( descr[i] ) ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while( descr[++i] ) {
|
||||
if( !DESC_CHAR( descr[i] ) ) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* OID Macros */
|
||||
|
||||
|
@ -217,6 +217,7 @@ typedef struct slap_ssf_set {
|
||||
#define SLAP_SCHERR_SYN_NOT_FOUND 13
|
||||
#define SLAP_SCHERR_MR_INCOMPLETE 14
|
||||
#define SLAP_SCHERR_NOT_SUPPORTED 15
|
||||
#define SLAP_SCHERR_BAD_DESCR 16
|
||||
|
||||
typedef struct slap_oid_macro {
|
||||
struct berval som_oid;
|
||||
|
Loading…
Reference in New Issue
Block a user