mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
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:
parent
cd89917abb
commit
179cd46266
1 changed files with 106 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue