From 6db0228171b4351614f102fba59552e778ec0441 Mon Sep 17 00:00:00 2001 From: Gary Williams Date: Mon, 30 Aug 1999 14:19:53 +0000 Subject: [PATCH] validate object class before checking required and allowed --- servers/slapd/schema.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index e347a5d693..51002f91f4 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -28,9 +28,11 @@ int oc_schema_check( Entry *e ) { Attribute *a, *aoc; + ObjectClass *oc; int i; int ret = 0; + /* find the object class attribute - could error out here */ if ( (aoc = attr_find( e->e_attrs, "objectclass" )) == NULL ) { Debug( LDAP_DEBUG_ANY, "No object class for entry (%s)\n", @@ -40,14 +42,23 @@ oc_schema_check( Entry *e ) /* check that the entry has required attrs for each oc */ for ( i = 0; aoc->a_vals[i] != NULL; i++ ) { - char *s = oc_check_required( e, aoc->a_vals[i]->bv_val ); - - if (s != NULL) { + if ( (oc = oc_find( aoc->a_vals[i]->bv_val )) == NULL ) { Debug( LDAP_DEBUG_ANY, - "Entry (%s), oc \"%s\" requires attr \"%s\"\n", - e->e_dn, aoc->a_vals[i]->bv_val, s ); + "Objectclass \"%s\" not defined", + aoc->a_vals[i]->bv_val, 0, 0 ); ret = 1; } + else + { + char *s = oc_check_required( e, aoc->a_vals[i]->bv_val ); + + if (s != NULL) { + Debug( LDAP_DEBUG_ANY, + "Entry (%s), oc \"%s\" requires attr \"%s\"\n", + e->e_dn, aoc->a_vals[i]->bv_val, s ); + ret = 1; + } + } } if ( ret != 0 ) { -- 2.39.5