From 179cd46266f7dc6c87587ead96b76d51b706366c Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sun, 3 Sep 2000 17:35:39 +0000 Subject: [PATCH] ITS#705: nisNetgroupTripleValidate ITS#706: bootParameterValidate Submitted by Stig Venass Modified by Kurt Zeilenga for stricter adherence to specification (RFC 2307). Portions Copyright 2000 Stig Venaas All rights reserved. Redistribution and use in source and binary forms are permitted without restriction or fee of any kind as long as this notice is preserved. This software is provided ``as is'' without express or implied warranty. --- servers/slapd/schema_init.c | 108 +++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 2 deletions(-) diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 9c8d48a25d..25d06d3748 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -19,8 +19,6 @@ /* recycled validatation routines */ #define berValidate blobValidate -#define nisNetgroupTripleValidate printableStringValidate -#define bootParameterValidate printableStringValidate /* unimplemented validators */ #define bitStringValidate NULL @@ -2166,6 +2164,112 @@ generalizedTimeNormalize( return LDAP_SUCCESS; } +static int +nisNetgroupTripleValidate( + Syntax *syntax, + struct berval *val ) +{ + char *p, *e; + int commas = 0; + + if ( val->bv_len == 0 ) { + return LDAP_INVALID_SYNTAX; + } + + p = (char *)val->bv_val; + e = p + val->bv_len; + +#if 0 + /* syntax does not allow leading white space */ + /* Ignore initial whitespace */ + while ( ( p < e ) && ASCII_SPACE( *p ) ) { + p++; + } +#endif + + if ( *p != '(' /*')'*/ ) { + return LDAP_INVALID_SYNTAX; + } + + for ( p++; ( p < e ) && ( *p != ')' ); p++ ) { + if ( *p == ',' ) { + commas++; + if ( commas > 2 ) { + return LDAP_INVALID_SYNTAX; + } + + } else if ( !ATTR_CHAR( *p ) ) { + return LDAP_INVALID_SYNTAX; + } + } + + if ( ( commas != 2 ) || ( *p != /*'('*/ ')' ) ) { + return LDAP_INVALID_SYNTAX; + } + + p++; + +#if 0 + /* syntax does not allow trailing white space */ + /* Ignore trailing whitespace */ + while ( ( p < e ) && ASCII_SPACE( *p ) ) { + p++; + } +#endif + + if (p != e) { + return LDAP_INVALID_SYNTAX; + } + + return LDAP_SUCCESS; +} + +static int +bootParameterValidate( + Syntax *syntax, + struct berval *val ) +{ + char *p, *e; + + if ( val->bv_len == 0 ) { + return LDAP_INVALID_SYNTAX; + } + + p = (char *)val->bv_val; + e = p + val->bv_len; + + /* key */ + for (; ( p < e ) && ( *p != '=' ); p++ ) { + if ( !ATTR_CHAR( *p ) ) { + return LDAP_INVALID_SYNTAX; + } + } + + if ( *p != '=' ) { + return LDAP_INVALID_SYNTAX; + } + + /* server */ + for ( p++; ( p < e ) && ( *p != ':' ); p++ ) { + if ( !ATTR_CHAR( *p ) ) { + return LDAP_INVALID_SYNTAX; + } + } + + if ( *p != ':' ) { + return LDAP_INVALID_SYNTAX; + } + + /* path */ + for ( p++; p < e; p++ ) { + if ( !ATTR_CHAR( *p ) ) { + return LDAP_INVALID_SYNTAX; + } + } + + return LDAP_SUCCESS; +} + struct syntax_defs_rec { char *sd_desc; int sd_flags; -- 2.39.5