ITS#705: nisNetgroupTripleValidate

ITS#706: bootParameterValidate
Submitted by Stig Venass <venaas@uninett.no>
Modified by Kurt Zeilenga <kurt@openldap.org> 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.
This commit is contained in:
Kurt Zeilenga 2000-09-03 17:35:39 +00:00
parent cd89917abb
commit 179cd46266

View file

@ -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;