~ubuntu-branches/ubuntu/hardy/openldap2.3/hardy-proposed

« back to all changes in this revision

Viewing changes to servers/slapd/schema_init.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2008-06-12 19:33:42 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080612193342-b1s0w22rpcmemotl
Tags: 2.4.9-0ubuntu0.8.04
* New upstream version: (LP: #237688)
  This verison fixes a number of bugs including syncrepl issues,
  assertion errors, and segmentation faults found in previous
  versions of openldap:
  http://www.openldap.org/software/release/changes.html.
  Dropped patches (included in the new upstream version):
   - debian/patches/entryCSN-backwards-compatibility (ITS #5348).
   - debian/patches/fix-notify-crasher.patch (ITS #5450).
   - debian/patches/libldap_r-link (ITS #4982).
   - debian/patches/sasl-cleartext-strncasecmp (ITS #5368).
   - debian/patches/slapd-tlsverifyclient-default (ITS #5360).
   - debian/patches/gnutls-ciphers patch (ITS #5341).
   - debian/patches/SECURITY_CVE-2008-0658.patch (#ITS 5358).
* debian/patches/fix-syncrepl-oops: Fixes assertion when using syncrepl.
  (LP: #227178)
* debian/patches/fix-assertion-io.patch,
  debian/patches/fix-dnpretty-assertion.patch:
  Add information about the related bugs these patches fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* schema_init.c - init builtin schema */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/schema_init.c,v 1.386.2.17 2007/12/03 15:04:31 hyc Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/schema_init.c,v 1.386.2.20 2008/04/14 20:01:31 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
4
 *
5
 
 * Copyright 1998-2007 The OpenLDAP Foundation.
 
5
 * Copyright 1998-2008 The OpenLDAP Foundation.
6
6
 * All rights reserved.
7
7
 *
8
8
 * Redistribution and use in source and binary forms, with or without
2239
2239
                }
2240
2240
                rc = integerVal2Key( &values[i], &keys[i], &itmp, ctx );
2241
2241
                if ( rc )
2242
 
                        goto leave;
 
2242
                        goto func_leave;
2243
2243
        }
2244
2244
        *keysp = keys;
2245
 
leave:
 
2245
func_leave:
2246
2246
        if ( itmp.bv_val != ibuf ) {
2247
2247
                slap_sl_free( itmp.bv_val, ctx );
2248
2248
        }
3142
3142
        sn2.bv_len = sn.bv_len;
3143
3143
        if ( lutil_str2bin( &sn, &sn2, ctx )) {
3144
3144
                rc = LDAP_INVALID_SYNTAX;
3145
 
                goto leave;
 
3145
                goto func_leave;
3146
3146
        }
3147
3147
 
3148
3148
        /* make room for sn + "$" */
3154
3154
                out->bv_len = 0;
3155
3155
                slap_sl_free( ni.bv_val, ctx );
3156
3156
                rc = LDAP_OTHER;
3157
 
                goto leave;
 
3157
                goto func_leave;
3158
3158
        }
3159
3159
 
3160
3160
        n = 0;
3192
3192
        Debug( LDAP_DEBUG_TRACE, "<<< serialNumberAndIssuerNormalize: <%s>\n",
3193
3193
                out->bv_val, 0, 0 );
3194
3194
 
3195
 
leave:
 
3195
func_leave:
3196
3196
        if ( stmp != sbuf )
3197
3197
                slap_sl_free( stmp, ctx );
3198
3198
        slap_sl_free( ni.bv_val, ctx );
3561
3561
        return hexValidate( NULL, &bv );
3562
3562
}
3563
3563
 
 
3564
/* Normalize a CSN in OpenLDAP 2.1 format */
 
3565
static int
 
3566
csnNormalize21(
 
3567
        slap_mask_t usage,
 
3568
        Syntax *syntax,
 
3569
        MatchingRule *mr,
 
3570
        struct berval *val,
 
3571
        struct berval *normalized,
 
3572
        void *ctx )
 
3573
{
 
3574
        struct berval   gt, cnt, sid, mod;
 
3575
        struct berval   bv;
 
3576
        char            buf[ STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss" ) + 1 ];
 
3577
        char            *ptr;
 
3578
        int             i;
 
3579
 
 
3580
        assert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) != 0 );
 
3581
        assert( !BER_BVISEMPTY( val ) );
 
3582
 
 
3583
        gt = *val;
 
3584
 
 
3585
        ptr = ber_bvchr( &gt, '#' );
 
3586
        if ( ptr == NULL || ptr - gt.bv_val == gt.bv_len ) {
 
3587
                return LDAP_INVALID_SYNTAX;
 
3588
        }
 
3589
 
 
3590
        gt.bv_len = ptr - gt.bv_val;
 
3591
        if ( gt.bv_len != STRLENOF( "YYYYmmddHH:MM:SSZ" ) ) {
 
3592
                return LDAP_INVALID_SYNTAX;
 
3593
        }
 
3594
 
 
3595
        if ( gt.bv_val[ 10 ] != ':' || gt.bv_val[ 13 ] != ':' ) {
 
3596
                return LDAP_INVALID_SYNTAX;
 
3597
        }
 
3598
 
 
3599
        cnt.bv_val = ptr + 1;
 
3600
        cnt.bv_len = val->bv_len - ( cnt.bv_val - val->bv_val );
 
3601
 
 
3602
        ptr = ber_bvchr( &cnt, '#' );
 
3603
        if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) {
 
3604
                return LDAP_INVALID_SYNTAX;
 
3605
        }
 
3606
 
 
3607
        cnt.bv_len = ptr - cnt.bv_val;
 
3608
        if ( cnt.bv_len != STRLENOF( "0x0000" ) ) {
 
3609
                return LDAP_INVALID_SYNTAX;
 
3610
        }
 
3611
 
 
3612
        if ( strncmp( cnt.bv_val, "0x", STRLENOF( "0x" ) ) != 0 ) {
 
3613
                return LDAP_INVALID_SYNTAX;
 
3614
        }
 
3615
 
 
3616
        cnt.bv_val += STRLENOF( "0x" );
 
3617
        cnt.bv_len -= STRLENOF( "0x" );
 
3618
 
 
3619
        sid.bv_val = ptr + 1;
 
3620
        sid.bv_len = val->bv_len - ( sid.bv_val - val->bv_val );
 
3621
                
 
3622
        ptr = ber_bvchr( &sid, '#' );
 
3623
        if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) {
 
3624
                return LDAP_INVALID_SYNTAX;
 
3625
        }
 
3626
 
 
3627
        sid.bv_len = ptr - sid.bv_val;
 
3628
        if ( sid.bv_len != STRLENOF( "0" ) ) {
 
3629
                return LDAP_INVALID_SYNTAX;
 
3630
        }
 
3631
 
 
3632
        mod.bv_val = ptr + 1;
 
3633
        mod.bv_len = val->bv_len - ( mod.bv_val - val->bv_val );
 
3634
        if ( mod.bv_len != STRLENOF( "0000" ) ) {
 
3635
                return LDAP_INVALID_SYNTAX;
 
3636
        }
 
3637
 
 
3638
        bv.bv_len = STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss" );
 
3639
        bv.bv_val = buf;
 
3640
 
 
3641
        ptr = bv.bv_val;
 
3642
        ptr = lutil_strncopy( ptr, gt.bv_val, STRLENOF( "YYYYmmddHH" ) );
 
3643
        ptr = lutil_strncopy( ptr, &gt.bv_val[ STRLENOF( "YYYYmmddHH:" ) ],
 
3644
                STRLENOF( "MM" ) );
 
3645
        ptr = lutil_strncopy( ptr, &gt.bv_val[ STRLENOF( "YYYYmmddHH:MM:" ) ],
 
3646
                STRLENOF( "SS" ) );
 
3647
        ptr = lutil_strcopy( ptr, ".000000Z#00" );
 
3648
        ptr = lutil_strncopy( ptr, cnt.bv_val, cnt.bv_len );
 
3649
        *ptr++ = '#';
 
3650
        *ptr++ = '0';
 
3651
        *ptr++ = '0';
 
3652
        *ptr++ = sid.bv_val[ 0 ];
 
3653
        *ptr++ = '#';
 
3654
        *ptr++ = '0';
 
3655
        *ptr++ = '0';
 
3656
        for ( i = 0; i < mod.bv_len; i++ ) {
 
3657
                *ptr++ = TOLOWER( mod.bv_val[ i ] );
 
3658
        }
 
3659
        *ptr = '\0';
 
3660
 
 
3661
        assert( ptr - bv.bv_val == bv.bv_len );
 
3662
 
 
3663
        if ( csnValidate( syntax, &bv ) != LDAP_SUCCESS ) {
 
3664
                return LDAP_INVALID_SYNTAX;
 
3665
        }
 
3666
 
 
3667
        ber_dupbv_x( normalized, &bv, ctx );
 
3668
 
 
3669
        return LDAP_SUCCESS;
 
3670
}
 
3671
 
3564
3672
/* Normalize a CSN in OpenLDAP 2.3 format */
3565
3673
static int
3566
3674
csnNormalize23(
3572
3680
        void *ctx )
3573
3681
{
3574
3682
        struct berval   gt, cnt, sid, mod;
 
3683
        struct berval   bv;
 
3684
        char            buf[ STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss" ) + 1 ];
3575
3685
        char            *ptr;
3576
3686
        int             i;
3577
3687
 
3586
3696
        }
3587
3697
 
3588
3698
        gt.bv_len = ptr - gt.bv_val;
3589
 
        assert( gt.bv_len == STRLENOF( "YYYYmmddHHMMSSZ" ) );
 
3699
        if ( gt.bv_len != STRLENOF( "YYYYmmddHHMMSSZ" ) ) {
 
3700
                return LDAP_INVALID_SYNTAX;
 
3701
        }
3590
3702
 
3591
3703
        cnt.bv_val = ptr + 1;
3592
3704
        cnt.bv_len = val->bv_len - ( cnt.bv_val - val->bv_val );
3597
3709
        }
3598
3710
 
3599
3711
        cnt.bv_len = ptr - cnt.bv_val;
3600
 
        assert( cnt.bv_len == STRLENOF( "000000" ) );
 
3712
        if ( cnt.bv_len != STRLENOF( "000000" ) ) {
 
3713
                return LDAP_INVALID_SYNTAX;
 
3714
        }
3601
3715
 
3602
3716
        sid.bv_val = ptr + 1;
3603
3717
        sid.bv_len = val->bv_len - ( sid.bv_val - val->bv_val );
3608
3722
        }
3609
3723
 
3610
3724
        sid.bv_len = ptr - sid.bv_val;
3611
 
        assert( sid.bv_len == STRLENOF( "00" ) );
 
3725
        if ( sid.bv_len != STRLENOF( "00" ) ) {
 
3726
                return LDAP_INVALID_SYNTAX;
 
3727
        }
3612
3728
 
3613
3729
        mod.bv_val = ptr + 1;
3614
3730
        mod.bv_len = val->bv_len - ( mod.bv_val - val->bv_val );
3615
 
        assert( mod.bv_len == STRLENOF( "000000" ) );
3616
 
 
3617
 
        normalized->bv_len = STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss" );
3618
 
        normalized->bv_val = ber_memalloc_x( normalized->bv_len + 1, ctx );
3619
 
 
3620
 
        ptr = normalized->bv_val;
 
3731
        if ( mod.bv_len != STRLENOF( "000000" ) ) {
 
3732
                return LDAP_INVALID_SYNTAX;
 
3733
        }
 
3734
 
 
3735
        bv.bv_len = STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss" );
 
3736
        bv.bv_val = buf;
 
3737
 
 
3738
        ptr = bv.bv_val;
3621
3739
        ptr = lutil_strncopy( ptr, gt.bv_val, gt.bv_len - 1 );
3622
3740
        ptr = lutil_strcopy( ptr, ".000000Z#" );
3623
3741
        ptr = lutil_strncopy( ptr, cnt.bv_val, cnt.bv_len );
3632
3750
        }
3633
3751
        *ptr = '\0';
3634
3752
 
3635
 
        assert( ptr - normalized->bv_val == normalized->bv_len );
 
3753
        assert( ptr - bv.bv_val == bv.bv_len );
 
3754
        if ( csnValidate( syntax, &bv ) != LDAP_SUCCESS ) {
 
3755
                return LDAP_INVALID_SYNTAX;
 
3756
        }
 
3757
 
 
3758
        ber_dupbv_x( normalized, &bv, ctx );
3636
3759
 
3637
3760
        return LDAP_SUCCESS;
3638
3761
}
3666
3789
                return csnNormalize23( usage, syntax, mr, val, normalized, ctx );
3667
3790
        }
3668
3791
 
3669
 
        assert( val->bv_len == STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss" ) );
 
3792
        if ( val->bv_len == STRLENOF( "YYYYmmddHH:MM:SSZ#0xSSSS#I#ssss" ) ) {
 
3793
                /* Openldap 2.1 */
 
3794
 
 
3795
                return csnNormalize21( usage, syntax, mr, val, normalized, ctx );
 
3796
        }
 
3797
 
 
3798
        if ( val->bv_len != STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ#SSSSSS#SID#ssssss" ) ) {
 
3799
                return LDAP_INVALID_SYNTAX;
 
3800
        }
3670
3801
 
3671
3802
        ptr = ber_bvchr( val, '#' );
3672
3803
        if ( ptr == NULL || ptr - val->bv_val == val->bv_len ) {
3673
3804
                return LDAP_INVALID_SYNTAX;
3674
3805
        }
3675
3806
 
3676
 
        assert( ptr - val->bv_val == STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ" ) );
 
3807
        if ( ptr - val->bv_val != STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ" ) ) {
 
3808
                return LDAP_INVALID_SYNTAX;
 
3809
        }
3677
3810
 
3678
3811
        cnt.bv_val = ptr + 1;
3679
3812
        cnt.bv_len = val->bv_len - ( cnt.bv_val - val->bv_val );
3683
3816
                return LDAP_INVALID_SYNTAX;
3684
3817
        }
3685
3818
 
3686
 
        assert( ptr - cnt.bv_val == STRLENOF( "000000" ) );
 
3819
        if ( ptr - cnt.bv_val != STRLENOF( "000000" ) ) {
 
3820
                return LDAP_INVALID_SYNTAX;
 
3821
        }
3687
3822
 
3688
3823
        sid.bv_val = ptr + 1;
3689
3824
        sid.bv_len = val->bv_len - ( sid.bv_val - val->bv_val );
3694
3829
        }
3695
3830
 
3696
3831
        sid.bv_len = ptr - sid.bv_val;
3697
 
        assert( sid.bv_len == STRLENOF( "000" ) );
 
3832
        if ( sid.bv_len != STRLENOF( "000" ) ) {
 
3833
                return LDAP_INVALID_SYNTAX;
 
3834
        }
3698
3835
 
3699
3836
        mod.bv_val = ptr + 1;
3700
3837
        mod.bv_len = val->bv_len - ( mod.bv_val - val->bv_val );
3701
3838
 
3702
 
        assert( mod.bv_len == STRLENOF( "000000" ) );
 
3839
        if ( mod.bv_len != STRLENOF( "000000" ) ) {
 
3840
                return LDAP_INVALID_SYNTAX;
 
3841
        }
3703
3842
 
3704
3843
        ber_dupbv_x( normalized, val, ctx );
3705
3844