Skip to content
Snippets Groups Projects
Commit 6b63e25b authored by Howard Chu's avatar Howard Chu
Browse files

Check for numeric syntaxes

parent 7dde9e0b
No related branches found
No related tags found
No related merge requests found
......@@ -81,12 +81,14 @@ static slap_verbmasks sorts[] = {
{ BER_BVNULL, 0 }
};
static Syntax *syn_numericString;
static int
valsort_cf_func(ConfigArgs *c) {
slap_overinst *on = (slap_overinst *)c->bi;
valsort_info vitmp, *vi;
const char *text = NULL;
int i;
int i, is_numeric;
struct berval bv = BER_BVNULL;
if ( c->op == SLAP_CONFIG_EMIT ) {
......@@ -159,6 +161,9 @@ valsort_cf_func(ConfigArgs *c) {
c->log, c->msg, c->argv[1] );
return(0);
}
is_numeric = ( vitmp.vi_ad->ad_type->sat_syntax == syn_numericString ||
vitmp.vi_ad->ad_type->sat_syntax == slap_schema.si_syn_integer ) ? 1
: 0;
ber_str2bv( c->argv[2], 0, 0, &bv );
i = dnNormalize( 0, NULL, NULL, &bv, &vitmp.vi_dn, NULL );
if ( i ) {
......@@ -185,6 +190,13 @@ valsort_cf_func(ConfigArgs *c) {
}
vitmp.vi_sort |= sorts[i].mask;
}
if (( vitmp.vi_sort & VALSORT_NUMERIC ) && !is_numeric ) {
sprintf( c->msg, "<%s> numeric sort specified for non-numeric syntax",
c->argv[0] );
Debug( LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
c->log, c->msg, c->argv[1] );
return(1);
}
vi = ch_malloc( sizeof(valsort_info) );
*vi = vitmp;
vi->vi_next = on->on_bi.bi_private;
......@@ -485,6 +497,8 @@ int valsort_init()
valsort.on_bi.bi_cf_ocs = valsort_cfocs;
syn_numericString = syn_find( "1.3.6.1.4.1.1466.115.121.1.36" );
rc = config_register_schema( valsort_cfats, valsort_cfocs );
if ( rc ) return rc;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment