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

« back to all changes in this revision

Viewing changes to clients/tools/common.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2008-07-31 16:06:53 UTC
  • mfrom: (16.1.3 hardy-proposed)
  • Revision ID: james.westby@ubuntu.com-20080731160653-np1dr19qfutmqb0v
Tags: 2.4.9-0ubuntu0.8.04.1
* SECURITY UPDATE: denial of service via broken BER decoding.
* Added debian/patches/security-ber-decoding.patch: upstream fixes.
* References
  CVE-2008-2952

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* common.c - common routines for the ldap client tools */
2
 
/* $OpenLDAP: pkg/ldap/clients/tools/common.c,v 1.78.2.4 2007/08/31 23:13:50 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/clients/tools/common.c,v 1.78.2.7 2008/02/11 23:26:38 kurt 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
 * Portions Copyright 2003 Kurt D. Zeilenga.
7
7
 * Portions Copyright 2003 IBM Corporation.
8
8
 * All rights reserved.
149
149
};
150
150
 
151
151
/* "features" */
152
 
static int      gotintr;
153
 
static int      abcan;
 
152
enum { Intr_None = 0, Intr_Abandon, Intr_Cancel, Intr_Ignore }; 
 
153
static volatile sig_atomic_t    gotintr, abcan;
154
154
 
155
155
 
156
156
#ifdef LDAP_CONTROL_X_SESSION_TRACKING
223
223
#ifdef HAVE_TLS
224
224
        ldap_pvt_tls_destroy();
225
225
#endif
 
226
 
 
227
        if ( ldapuri != NULL ) {
 
228
                ber_memfree( ldapuri );
 
229
                ldapuri = NULL;
 
230
        }
 
231
 
 
232
        if ( pr_cookie.bv_val != NULL ) {
 
233
                ber_memfree( pr_cookie.bv_val );
 
234
                pr_cookie.bv_val = NULL;
 
235
                pr_cookie.bv_len = 0;
 
236
        }
226
237
}
227
238
 
228
239
void
558
569
 
559
570
                        /* this shouldn't go here, really; but it's a feature... */
560
571
                        } else if ( strcasecmp( control, "abandon" ) == 0 ) {
561
 
                                abcan = LDAP_REQ_ABANDON;
 
572
                                abcan = Intr_Abandon;
562
573
                                if ( crit ) {
563
574
                                        gotintr = abcan;
564
575
                                }
565
576
 
566
577
                        } else if ( strcasecmp( control, "cancel" ) == 0 ) {
567
 
                                abcan = LDAP_REQ_EXTENDED;
 
578
                                abcan = Intr_Cancel;
568
579
                                if ( crit ) {
569
580
                                        gotintr = abcan;
570
581
                                }
571
582
 
572
583
                        } else if ( strcasecmp( control, "ignore" ) == 0 ) {
573
 
                                abcan = -1;
 
584
                                abcan = Intr_Ignore;
574
585
                                if ( crit ) {
575
586
                                        gotintr = abcan;
576
587
                                }
746
757
                case 'P':
747
758
                        ival = strtol( optarg, &next, 10 );
748
759
                        if ( next == NULL || next[0] != '\0' ) {
749
 
                                fprintf( stderr, "%s: unabel to parse protocol version \"%s\"\n", prog, optarg );
 
760
                                fprintf( stderr, "%s: unable to parse protocol version \"%s\"\n", prog, optarg );
750
761
                                exit( EXIT_FAILURE );
751
762
                        }
752
763
                        switch( ival ) {
1720
1731
        int     rc;
1721
1732
 
1722
1733
        switch ( gotintr ) {
1723
 
        case LDAP_REQ_EXTENDED:
 
1734
        case Intr_Cancel:
1724
1735
                rc = ldap_cancel_s( ld, msgid, NULL, NULL );
1725
1736
                fprintf( stderr, "got interrupt, cancel got %d: %s\n",
1726
1737
                                rc, ldap_err2string( rc ) );
1727
1738
                return -1;
1728
1739
 
1729
 
        case LDAP_REQ_ABANDON:
 
1740
        case Intr_Abandon:
1730
1741
                rc = ldap_abandon_ext( ld, msgid, NULL, NULL );
1731
1742
                fprintf( stderr, "got interrupt, abandon got %d: %s\n",
1732
1743
                                rc, ldap_err2string( rc ) );
1733
1744
                return -1;
1734
1745
 
1735
 
        case -1:
 
1746
        case Intr_Ignore:
1736
1747
                /* just unbind, ignoring the request */
1737
1748
                return -1;
1738
1749
        }