mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-18 11:05:48 +08:00
Move most of the new ber_*cmp routines to lber_pvt.h to keep them private,
rework them slightly to avoid computations which might result in underflow. Rename them for consistency with other berval routines. Remove some utf8 lint.
This commit is contained in:
parent
356a98a363
commit
7f0289a390
@ -580,23 +580,10 @@ ber_bvarray_free LDAP_P(( BerVarray p ));
|
||||
LBER_F( int )
|
||||
ber_bvarray_add LDAP_P(( BerVarray *p, BerValue *bv ));
|
||||
|
||||
#define ber_memcmp(v1,v2) \
|
||||
((v1)->bv_len == (v2)->bv_len ? \
|
||||
memcmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) : \
|
||||
(v1)->bv_len - (v2)->bv_len )
|
||||
|
||||
#define ber_cmp(v1,v2) \
|
||||
((v1)->bv_len == (v2)->bv_len ? \
|
||||
strcmp((v1)->bv_val, (v2)->bv_val) : \
|
||||
(v1)->bv_len - (v2)->bv_len )
|
||||
|
||||
#define ber_casecmp(v1,v2) \
|
||||
((v1)->bv_len == (v2)->bv_len ? \
|
||||
strcasecmp((v1)->bv_val, (v2)->bv_val) : \
|
||||
(v1)->bv_len - (v2)->bv_len )
|
||||
|
||||
#define ber_charcmp(v1,c) \
|
||||
((v1)->bv_len == 1 ? (v1)->bv_val[0] == c : 0)
|
||||
#define ber_bvcmp(v1,v2) \
|
||||
((v1)->bv_len < (v2)->bv_len \
|
||||
? -1 : ((v1)->bv_len > (v2)->bv_len \
|
||||
? 1 : memcmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
|
||||
|
||||
/*
|
||||
* error.c
|
||||
|
@ -61,6 +61,25 @@ ber_pvt_sb_copy_out LDAP_P(( Sockbuf_Buf *sbb, char *buf, ber_len_t len ));
|
||||
LBER_F( int )
|
||||
ber_pvt_socket_set_nonblock LDAP_P(( ber_socket_t sd, int nb ));
|
||||
|
||||
|
||||
#if 0
|
||||
#define ber_bvstrcmp(v1,v2) \
|
||||
((v1)->bv_len < (v2)->bv_len \
|
||||
? -1 : ((v1)->bv_len > (v2)->bv_len \
|
||||
? 1 : strncmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
|
||||
#else
|
||||
/* avoid strncmp() */
|
||||
#define ber_bvstrcmp(v1,v2) ber_bvcmp((v1),(v2))
|
||||
#endif
|
||||
|
||||
#define ber_bvstrcasecmp(v1,v2) \
|
||||
((v1)->bv_len < (v2)->bv_len \
|
||||
? -1 : ((v1)->bv_len > (v2)->bv_len \
|
||||
? 1 : strncasecmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
|
||||
|
||||
#define ber_bvccmp(v1,c) \
|
||||
((v1)->bv_len == 1 ? (v1)->bv_val[0] == c : 0)
|
||||
|
||||
LDAP_END_DECL
|
||||
|
||||
#endif
|
||||
|
@ -112,11 +112,14 @@ int ldap_utf8_charlen( const char * p )
|
||||
*/
|
||||
|
||||
/* mask of required bits in second octet */
|
||||
const char ldap_utf8_mintab[] = {
|
||||
0x20, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x30, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x38, 0x80, 0x80, 0x80, 0x3c, 0x80, 0x00, 0x00 };
|
||||
#undef c
|
||||
#define c const char
|
||||
c ldap_utf8_mintab[] = {
|
||||
(c)0x20, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80,
|
||||
(c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80,
|
||||
(c)0x30, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80,
|
||||
(c)0x38, (c)0x80, (c)0x80, (c)0x80, (c)0x3c, (c)0x80, (c)0x00, (c)0x00 };
|
||||
#undef c
|
||||
|
||||
int ldap_utf8_charlen2( const char * p )
|
||||
{
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "slap.h"
|
||||
#include "sets.h"
|
||||
#include "lber_pvt.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -531,17 +532,17 @@ acl_mask(
|
||||
* user is bound as somebody in the same namespace as
|
||||
* the entry, OR the given dn matches the dn pattern
|
||||
*/
|
||||
if ( ber_cmp( &b->a_dn_pat, &aci_bv_anonymous ) == 0 ) {
|
||||
if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_anonymous ) == 0 ) {
|
||||
if ( op->o_ndn.bv_len != 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if ( ber_cmp( &b->a_dn_pat, &aci_bv_users ) == 0 ) {
|
||||
} else if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_users ) == 0 ) {
|
||||
if ( op->o_ndn.bv_len == 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if ( ber_cmp( &b->a_dn_pat, &aci_bv_self ) == 0 ) {
|
||||
} else if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_self ) == 0 ) {
|
||||
if ( op->o_ndn.bv_len == 0 ) {
|
||||
continue;
|
||||
}
|
||||
@ -552,7 +553,7 @@ acl_mask(
|
||||
|
||||
} else if ( b->a_dn_style == ACL_STYLE_REGEX ) {
|
||||
if ( b->a_dn_pat.bv_len != 1 ||
|
||||
ber_charcmp( &b->a_dn_pat, '*' ) != 0 ) {
|
||||
ber_bvccmp( &b->a_dn_pat, '*' ) != 0 ) {
|
||||
int ret = regex_matches( b->a_dn_pat.bv_val,
|
||||
op->o_ndn.bv_val, e->e_ndn, matches );
|
||||
|
||||
@ -601,7 +602,6 @@ acl_mask(
|
||||
|
||||
if ( strcmp( b->a_dn_pat.bv_val, op->o_ndn.bv_val + odnlen - patlen ) != 0 )
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ LDAP_SLAPD_F (void) slapd_clr_read LDAP_P((ber_socket_t s, int wake));
|
||||
* dn.c
|
||||
*/
|
||||
|
||||
#define dn_match(dn1, dn2) ( ber_cmp((dn1), (dn2)) == 0 )
|
||||
#define dn_match(dn1, dn2) ( ber_bvcmp((dn1), (dn2)) == 0 )
|
||||
|
||||
LDAP_SLAPD_F (int) dnValidate LDAP_P((
|
||||
Syntax *syntax,
|
||||
|
@ -175,7 +175,7 @@ typedef struct slap_ssf_set {
|
||||
|
||||
#define SLAP_INDEX_DEFAULT SLAP_INDEX_EQUALITY
|
||||
|
||||
#define IS_SLAP_INDEX(mask, type) (((mask) & (type)) == (type) )
|
||||
#define IS_SLAP_INDEX(mask, type) (((mask) & (type)) == (type))
|
||||
|
||||
#define SLAP_INDEX_SUBSTR_TYPE 0x0F00UL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user