mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
ITS#8733 Allow a raw integer to be decoded from a berval
This commit is contained in:
parent
62811e8f65
commit
ff2d7cc798
@ -280,6 +280,11 @@ ber_get_enum LDAP_P((
|
||||
BerElement *ber,
|
||||
ber_int_t *num ));
|
||||
|
||||
LBER_F( int )
|
||||
ber_decode_int LDAP_P((
|
||||
const struct berval *bv,
|
||||
ber_int_t *num ));
|
||||
|
||||
LBER_F( ber_tag_t )
|
||||
ber_get_stringb LDAP_P((
|
||||
BerElement *ber,
|
||||
|
@ -283,21 +283,28 @@ ber_get_int(
|
||||
BerElement *ber,
|
||||
ber_int_t *num )
|
||||
{
|
||||
ber_tag_t tag;
|
||||
ber_len_t len;
|
||||
struct berval bv;
|
||||
ber_tag_t tag = ber_skip_element( ber, &bv );
|
||||
|
||||
if ( tag == LBER_DEFAULT ) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
return ber_decode_int( &bv, num ) ? LBER_DEFAULT : tag;
|
||||
}
|
||||
|
||||
int
|
||||
ber_decode_int( const struct berval *bv, ber_int_t *num )
|
||||
{
|
||||
ber_len_t len = bv->bv_len;
|
||||
if ( len > sizeof(ber_int_t) )
|
||||
return -1;
|
||||
|
||||
assert( num != NULL );
|
||||
|
||||
tag = ber_skip_element( ber, &bv );
|
||||
len = bv.bv_len;
|
||||
if ( tag == LBER_DEFAULT || len > sizeof(ber_int_t) ) {
|
||||
return LBER_DEFAULT;
|
||||
}
|
||||
|
||||
/* parse two's complement integer */
|
||||
if( len ) {
|
||||
unsigned char *buf = (unsigned char *) bv.bv_val;
|
||||
unsigned char *buf = (unsigned char *) bv->bv_val;
|
||||
ber_len_t i;
|
||||
ber_int_t netnum = buf[0] & 0xff;
|
||||
|
||||
@ -315,7 +322,7 @@ ber_get_int(
|
||||
*num = 0;
|
||||
}
|
||||
|
||||
return tag;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ber_tag_t
|
||||
|
Loading…
Reference in New Issue
Block a user