From: Howard Chu Date: Fri, 9 Apr 2004 14:56:03 +0000 (+0000) Subject: Import ITS#2920, ITS#3065 fixes from HEAD X-Git-Tag: OPENLDAP_REL_ENG_2_1_30~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63f6d61e6ba8a41f41bcb5ee2a3db7980a572f60;p=thirdparty%2Fopenldap.git Import ITS#2920, ITS#3065 fixes from HEAD --- diff --git a/libraries/libldap/schema.c b/libraries/libldap/schema.c index 0ac55075bf..df3e7ba53c 100644 --- a/libraries/libldap/schema.c +++ b/libraries/libldap/schema.c @@ -1,7 +1,16 @@ /* $OpenLDAP$ */ -/* - * Copyright 1999-2003 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2004 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . */ /* * schema.c: parsing routines used by servers and clients to process @@ -1173,8 +1182,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); @@ -1183,7 +1192,6 @@ parse_qdescrs(const char **sp, int *code) return(NULL); } } - res[pos] = NULL; parse_whsp(sp); return(res); } else if ( kind == TK_QDESCR ) { @@ -1301,8 +1309,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); @@ -1331,8 +1339,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); @@ -1347,7 +1355,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 || @@ -2679,9 +2686,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);