From: Kurt Zeilenga Date: Wed, 19 May 1999 06:13:44 +0000 (+0000) Subject: Add UL to LBER tags. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~52 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6ee995f52870a5a479344f22f7d3aceca0c6a12f;p=openldap Add UL to LBER tags. --- diff --git a/libraries/liblber/bprint.c b/libraries/liblber/bprint.c index 34832a6b2c..ca65c82f48 100644 --- a/libraries/liblber/bprint.c +++ b/libraries/liblber/bprint.c @@ -141,8 +141,8 @@ ber_bprint( out[ i+1 ] = *data; } else { #endif - out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ]; - out[ i+1 ] = hexdig[ *data & 0x0f ]; + out[ i ] = hexdig[ ( *data & 0xf0U ) >> 4 ]; + out[ i+1 ] = hexdig[ *data & 0x0fU ]; #ifndef LDAP_HEX } #endif @@ -249,4 +249,4 @@ ber_sos_dump( } (*ber_pvt_log_print)( "*** end dump ***\n" ); -} \ No newline at end of file +} diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index 1d87539e8a..d2e81df26e 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -104,8 +104,8 @@ ber_skip_tag( BerElement *ber, unsigned long *len ) *len = netlen = 0; if ( ber_read( ber, (char *) &lc, 1 ) != 1 ) return( LBER_DEFAULT ); - if ( lc & 0x80 ) { - noctets = (lc & 0x7f); + if ( lc & 0x80U ) { + noctets = (lc & 0x7fU); if ( (unsigned) noctets > sizeof(unsigned long) ) return( LBER_DEFAULT ); diff = sizeof(unsigned long) - noctets; @@ -694,8 +694,10 @@ va_dcl case 'v': /* sequence of strings */ sss = va_arg( ap, char *** ); if ( *sss ) { - for (j = 0; (*sss)[j]; j++) + for (j = 0; (*sss)[j]; j++) { free( (*sss)[j] ); + (*sss)[j] = NULL; + } free( *sss ); *sss = NULL; } diff --git a/libraries/liblber/encode.c b/libraries/liblber/encode.c index d3914c6151..9a8cd5572a 100644 --- a/libraries/liblber/encode.c +++ b/libraries/liblber/encode.c @@ -42,11 +42,11 @@ static int ber_calc_taglen( unsigned long tag ) { int i; - long mask; + unsigned long mask; /* find the first non-all-zero byte in the tag */ for ( i = sizeof(long) - 1; i > 0; i-- ) { - mask = (0xffL << (i * 8)); + mask = (0xffUL << (i * 8)); /* not all zero */ if ( tag & mask ) break; @@ -77,7 +77,7 @@ ber_calc_lenlen( unsigned long len ) * with bit 8 0. */ - if ( len <= 0x7F ) + if ( len <= 0x7FUL ) return( 1 ); /* @@ -85,11 +85,11 @@ ber_calc_lenlen( unsigned long len ) * length of the length, followed by the length itself. */ - if ( len <= 0xFF ) + if ( len <= 0xffUL ) return( 2 ); - if ( len <= 0xFFFFL ) + if ( len <= 0xffffUL ) return( 3 ); - if ( len <= 0xFFFFFFL ) + if ( len <= 0xffffffUL ) return( 4 ); return( 5 ); @@ -100,7 +100,7 @@ ber_put_len( BerElement *ber, unsigned long len, int nosos ) { int i; char lenlen; - long mask; + unsigned long mask; unsigned long netlen; assert( ber != NULL ); @@ -123,7 +123,7 @@ ber_put_len( BerElement *ber, unsigned long len, int nosos ) /* find the first non-all-zero byte */ for ( i = sizeof(long) - 1; i > 0; i-- ) { - mask = (0xffL << (i * 8)); + mask = (0xffUL << (i * 8)); /* not all zero */ if ( len & mask ) break; @@ -131,7 +131,7 @@ ber_put_len( BerElement *ber, unsigned long len, int nosos ) lenlen = (unsigned char) ++i; if ( lenlen > 4 ) return( -1 ); - lenlen |= 0x80; + lenlen |= 0x80UL; /* write the length of the length */ if ( ber_write( ber, &lenlen, 1, nosos ) != 1 ) @@ -162,7 +162,7 @@ ber_put_int_or_enum( BerElement *ber, long num, unsigned long tag ) * high bit is clear - look for first non-all-zero byte */ for ( i = sizeof(long) - 1; i > 0; i-- ) { - mask = (0xffL << (i * 8)); + mask = (0xffUL << (i * 8)); if ( sign ) { /* not all ones */ @@ -179,7 +179,7 @@ ber_put_int_or_enum( BerElement *ber, long num, unsigned long tag ) * we now have the "leading byte". if the high bit on this * byte matches the sign bit, we need to "back up" a byte. */ - mask = (num & (0x80L << (i * 8))); + mask = (num & (0x80UL << (i * 8))); if ( (mask && !sign) || (sign && !mask) ) i++; @@ -355,8 +355,8 @@ int ber_put_boolean( BerElement *ber, int boolval, unsigned long tag ) { int taglen; - unsigned char trueval = 0xff; - unsigned char falseval = 0x00; + unsigned char trueval = 0xffU; + unsigned char falseval = 0x00U; assert( ber != NULL ); @@ -431,7 +431,7 @@ ber_put_seqorset( BerElement *ber ) { unsigned long len, netlen; int taglen, lenlen; - unsigned char ltag = 0x80 + FOUR_BYTE_LEN - 1; + unsigned char ltag = 0x80U + FOUR_BYTE_LEN - 1; Seqorset *next; Seqorset **sos = &ber->ber_sos; @@ -447,7 +447,7 @@ ber_put_seqorset( BerElement *ber ) len = (*sos)->sos_clen; netlen = AC_HTONL( len ); - if ( sizeof(long) > 4 && len > 0xFFFFFFFFL ) + if ( sizeof(long) > 4 && len > 0xffffffffUL ) return( -1 ); if ( ber->ber_options & LBER_USE_DER ) { @@ -502,7 +502,7 @@ ber_put_seqorset( BerElement *ber ) if ( ber->ber_options & LBER_USE_DER ) { ltag = (lenlen == 1) ? (unsigned char) len - : 0x80 + (lenlen - 1); + : 0x80UL + (lenlen - 1); } /* one byte of length length */ diff --git a/libraries/liblber/etest.c b/libraries/liblber/etest.c index 66ae72d585..b0cd89eafa 100644 --- a/libraries/liblber/etest.c +++ b/libraries/liblber/etest.c @@ -72,7 +72,7 @@ main( int argc, char **argv ) #ifndef notdef num = 7; - if ( ber_printf( ber, "{ti}", 0x1f44, num ) == -1 ) { + if ( ber_printf( ber, "{ti}", 0x1f44U, num ) == -1 ) { fprintf( stderr, "ber_printf returns -1" ); exit( 1 ); } diff --git a/libraries/liblber/io.c b/libraries/liblber/io.c index 31e872c647..74e3c2234d 100644 --- a/libraries/liblber/io.c +++ b/libraries/liblber/io.c @@ -480,8 +480,8 @@ get_lenbyte: unsigned char c; if (ber_pvt_sb_read( sb, (char *) &c, 1)<=0) return LBER_DEFAULT; - if (c & 0x80) { - int len = c & 0x7f; + if (c & 0x80U) { + int len = c & 0x7fU; if ( (len==0) || ((unsigned) len>sizeof( ber->ber_len ) ) ) { errno = ERANGE; return LBER_DEFAULT; diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index 1c5279da7e..46b84200d4 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -170,6 +170,7 @@ ldap_result2error( LDAP *ld, LDAPMessage *r, int freeit ) } else { rc = ber_scanf( &ber, "{ia}", &along, &ld->ld_error ); } + if ( rc == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; } else { diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index 816f150cf5..03a661e3ad 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -274,12 +274,15 @@ int ldap_check_cache LDAP_P(( LDAP *ld, unsigned long msgtype, BerElement *reque /* * in controls.c */ -LDAPControl *ldap_control_dup LDAP_P(( const LDAPControl *ctrl )); -LDAPControl **ldap_controls_dup LDAP_P(( const LDAPControl **ctrls )); +LDAPControl *ldap_control_dup LDAP_P(( + const LDAPControl *ctrl )); + +LDAPControl **ldap_controls_dup LDAP_P(( + const LDAPControl **ctrls )); int ldap_int_get_controls LDAP_P(( BerElement *be, - LDAPControl ***cp)); + LDAPControl ***ctrlsp)); int ldap_int_put_controls LDAP_P(( LDAP *ld, diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index e42c95cd0e..152336f7be 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -261,10 +261,11 @@ open_ldap_connection( LDAP *ld, Sockbuf *sb, const char *host, int defport, ber_pvt_sb_set_io( sb, &ber_pvt_sb_io_tcp, NULL ); if ( krbinstancep != NULL ) { + char *c; #ifdef HAVE_KERBEROS if (( *krbinstancep = ldap_host_connected_to( sb )) != NULL && - ( p = strchr( *krbinstancep, '.' )) != NULL ) { - *p = '\0'; + ( c = strchr( *krbinstancep, '.' )) != NULL ) { + *c = '\0'; } #else /* HAVE_KERBEROS */ krbinstancep = NULL; diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index affb590d46..3da2edba64 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -327,9 +327,10 @@ try_read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, ber_clear( ber, 1 ); /* gack! */ return( -2 ); /* continue looking */ } - Debug( LDAP_DEBUG_TRACE, "got %s msgid %ld, original id %d\n", - ( tag == LDAP_RES_SEARCH_ENTRY ) ? "entry" : "result", id, - lr->lr_origid ); + Debug( LDAP_DEBUG_TRACE, "ldap_read: %s msgid %ld, original id %d\n", + ( tag == LDAP_RES_SEARCH_ENTRY ) ? "entry" : + ( tag == LDAP_RES_SEARCH_REFERENCE ) ? "reference" : "result", + id, lr->lr_origid ); id = lr->lr_origid; #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c index 23088a1166..66a69b8643 100644 --- a/libraries/libldap/test.c +++ b/libraries/libldap/test.c @@ -906,7 +906,7 @@ print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s ) /* if ( ld->ld_error != NULL && *ld->ld_error != '\0' ) fprintf( stderr, "Additional info: %s\n", ld->ld_error ); - if ( NAME_ERROR( ld->ld_errno ) && ld->ld_matched != NULL ) + if ( LDAP_NAME_ERROR( ld->ld_errno ) && ld->ld_matched != NULL ) fprintf( stderr, "Matched DN: %s\n", ld->ld_matched ); */ }