From b7d11180552b495ec34079a5578054c4d5e89473 Mon Sep 17 00:00:00 2001 From: Ludwig Krispenz Date: Oct 10 2019 08:57:02 +0000 Subject: Ticket - 50349 - additional fix: filter schema check must handle subtypes Bug: if the filter did contain an attribute with a subtype eg givenname;lang-de then the schema lookup failed. Fix: The subtype needs to be removed befor asi lookup Reviewed by: William, Thiery, Mark - thanks --- diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c index 8d218d4..7de006c 100644 --- a/ldap/servers/slapd/attrsyntax.c +++ b/ldap/servers/slapd/attrsyntax.c @@ -394,11 +394,33 @@ attr_syntax_get_by_name_locking_optional(const char *name, PRBool use_lock, PRUi * The main reason to use this over attr_syntax_get_by_name_locking_optional is to * avoid the reference count increment/decrement cycle when we only need a boolean * of existance, rather than retriving the reference to the attribute itself. + * + * But we do need to strip subtypes */ int32_t attr_syntax_exist_by_name_nolock(char *name) { struct asyntaxinfo *asi = NULL; - asi = (struct asyntaxinfo *)PL_HashTableLookup_const(name2asi, name); + char *check_name = NULL; + char *p = NULL; + int free_attr = 0; + + /* Ignore any attribute subtypes. */ + if ((p = strchr(name, ';'))) { + int check_len = p - name + 1; + + check_name = (char *)slapi_ch_malloc(check_len); + PR_snprintf(check_name, check_len, "%s", name); + free_attr = 1; + } else { + check_name = name; + } + + asi = (struct asyntaxinfo *)PL_HashTableLookup_const(name2asi, check_name); + + if (free_attr) { + slapi_ch_free_string(&check_name); + } + if (asi != NULL) { return 1; }