From: Kurt Zeilenga Date: Mon, 12 Apr 2004 17:11:08 +0000 (+0000) Subject: ITS#2920: add ditContentRule oidMacro support X-Git-Tag: OPENLDAP_REL_ENG_2_2_9~30 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4f36e835f0b3f09e507195d298af27e939066f97;p=openldap ITS#2920: add ditContentRule oidMacro support ITS#3065: fix parse_oid core dump --- diff --git a/libraries/libldap/schema.c b/libraries/libldap/schema.c index 9da7f35409..c413d1200d 100644 --- a/libraries/libldap/schema.c +++ b/libraries/libldap/schema.c @@ -1183,8 +1183,8 @@ parse_qdescrs(const char **sp, int *code) } res = res1; } - res[pos] = sval; - pos++; + res[pos++] = sval; + res[pos] = NULL; parse_whsp(sp); } else { LDAP_VFREE(res); @@ -1193,7 +1193,6 @@ parse_qdescrs(const char **sp, int *code) return(NULL); } } - res[pos] = NULL; parse_whsp(sp); return(res); } else if ( kind == TK_QDESCR ) { @@ -1311,8 +1310,8 @@ parse_oids(const char **sp, int *code, const int allow_quoted) kind = get_token(sp,&sval); if ( kind == TK_BAREWORD || ( allow_quoted && kind == TK_QDSTRING ) ) { - res[pos] = sval; - pos++; + res[pos++] = sval; + res[pos] = NULL; } else { *code = LDAP_SCHERR_UNEXPTOKEN; LDAP_FREE(sval); @@ -1341,8 +1340,8 @@ parse_oids(const char **sp, int *code, const int allow_quoted) } res = res1; } - res[pos] = sval; - pos++; + res[pos++] = sval; + res[pos] = NULL; } else { *code = LDAP_SCHERR_UNEXPTOKEN; LDAP_FREE(sval); @@ -1357,7 +1356,6 @@ parse_oids(const char **sp, int *code, const int allow_quoted) return NULL; } } - res[pos] = NULL; parse_whsp(sp); return(res); } else if ( kind == TK_BAREWORD || @@ -2689,9 +2687,36 @@ ldap_str2contentrule( LDAP_CONST char * s, savepos = ss; cr->cr_oid = ldap_int_parse_numericoid(&ss,code,0); if ( !cr->cr_oid ) { - *errp = ss; - ldap_contentrule_free(cr); - return NULL; + if ( (flags & LDAP_SCHEMA_ALLOW_ALL) && (ss == savepos) ) { + /* Backtracking */ + ss = savepos; + kind = get_token(&ss,&sval); + if ( kind == TK_BAREWORD ) { + if ( !strcmp(sval, "NAME") || + !strcmp(sval, "DESC") || + !strcmp(sval, "OBSOLETE") || + !strcmp(sval, "AUX") || + !strcmp(sval, "MUST") || + !strcmp(sval, "MAY") || + !strcmp(sval, "NOT") || + !strncmp(sval, "X-", 2) ) { + /* Missing OID, backtrack */ + ss = savepos; + } else if ( flags & + LDAP_SCHEMA_ALLOW_OID_MACRO ) { + /* Non-numerical OID, ignore */ + int len = ss-savepos; + cr->cr_oid = LDAP_MALLOC(len+1); + strncpy(cr->cr_oid, savepos, len); + cr->cr_oid[len] = 0; + } + } + LDAP_FREE(sval); + } else { + *errp = ss; + ldap_contentrule_free(cr); + return NULL; + } } parse_whsp(&ss);