Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
10ef5cf2
Commit
10ef5cf2
authored
Jul 24, 2007
by
Howard Chu
Browse files
ITS#5057 from HEAD
parent
07b8bdff
Changes
1
Hide whitespace changes
Inline
Side-by-side
servers/slapd/dn.c
View file @
10ef5cf2
...
@@ -262,81 +262,62 @@ rdnValidate(
...
@@ -262,81 +262,62 @@ rdnValidate(
* Note: the sorting can be slightly improved by sorting first
* Note: the sorting can be slightly improved by sorting first
* by attribute type length, then by alphabetical order.
* by attribute type length, then by alphabetical order.
*
*
* uses a
linear search
; should be fine since the number of AVAs in
* uses a
n insertion sort
; should be fine since the number of AVAs in
* a RDN should be limited.
* a RDN should be limited.
*/
*/
static
void
static
int
AVA_Sort
(
LDAPRDN
rdn
,
int
i
AVA
)
AVA_Sort
(
LDAPRDN
rdn
,
int
n
AVA
s
)
{
{
LDAPAVA
*
ava_i
;
int
i
;
int
i
;
LDAPAVA
*
ava_in
=
rdn
[
iAVA
];
assert
(
rdn
!=
NULL
);
assert
(
rdn
!=
NULL
);
assert
(
ava_in
!=
NULL
);
for
(
i
=
0
;
i
<
iAVA
;
i
++
)
{
LDAPAVA
*
ava
=
rdn
[
i
];
int
a
,
j
;
assert
(
ava
!=
NULL
);
for
(
i
=
1
;
i
<
nAVAs
;
i
++
)
{
LDAPAVA
*
ava_j
;
int
j
;
a
=
strcmp
(
ava_in
->
la_attr
.
bv_val
,
ava
->
la_attr
.
bv_val
);
ava_i
=
rdn
[
i
];
for
(
j
=
i
-
1
;
j
>=
0
;
j
--
)
{
int
a
;
if
(
a
>
0
)
{
ava_j
=
rdn
[
j
];
break
;
a
=
strcmp
(
ava_i
->
la_attr
.
bv_val
,
ava_j
->
la_attr
.
bv_val
);
}
while
(
a
==
0
)
{
if
(
a
==
0
)
{
int
v
,
d
;
int
d
;
d
=
ava_i
n
->
la_value
.
bv_len
-
ava
->
la_value
.
bv_len
;
d
=
ava_i
->
la_value
.
bv_len
-
ava
_j
->
la_value
.
bv_len
;
v
=
memcmp
(
ava_i
n
->
la_value
.
bv_val
,
a
=
memcmp
(
ava_i
->
la_value
.
bv_val
,
ava
->
la_value
.
bv_val
,
ava
_j
->
la_value
.
bv_val
,
d
<=
0
?
ava_i
n
->
la_value
.
bv_len
d
<=
0
?
ava_i
->
la_value
.
bv_len
:
ava
->
la_value
.
bv_len
);
:
ava
_j
->
la_value
.
bv_len
);
if
(
v
==
0
&&
d
!=
0
)
{
if
(
a
==
0
)
{
v
=
d
;
a
=
d
;
}
}
}
/* Duplicates are not allowed */
if
(
a
==
0
)
return
LDAP_INVALID_DN_SYNTAX
;
if
(
v
<=
0
)
{
if
(
a
>
0
)
/*
* got it!
*/
break
;
break
;
}
if
(
++
i
==
iAVA
)
{
/*
* already sorted
*/
return
;
}
ava
=
rdn
[
i
];
a
=
strcmp
(
ava_in
->
la_attr
.
bv_val
,
ava
->
la_attr
.
bv_val
);
}
/*
rdn
[
j
+
1
]
=
rdn
[
j
];
* move ahead
*/
for
(
j
=
iAVA
;
j
>
i
;
j
--
)
{
rdn
[
j
]
=
rdn
[
j
-
1
];
}
}
rdn
[
i
]
=
ava_in
;
rdn
[
j
+
1
]
=
ava_i
;
return
;
}
}
return
LDAP_SUCCESS
;
}
}
static
int
static
int
LDAPRDN_rewrite
(
LDAPRDN
rdn
,
unsigned
flags
,
void
*
ctx
)
LDAPRDN_rewrite
(
LDAPRDN
rdn
,
unsigned
flags
,
void
*
ctx
)
{
{
int
rc
;
int
rc
,
iAVA
,
do_sort
=
0
;
int
iAVA
;
for
(
iAVA
=
0
;
rdn
[
iAVA
];
iAVA
++
)
{
for
(
iAVA
=
0
;
rdn
[
iAVA
];
iAVA
++
)
{
LDAPAVA
*
ava
=
rdn
[
iAVA
];
LDAPAVA
*
ava
=
rdn
[
iAVA
];
AttributeDescription
*
ad
;
AttributeDescription
*
ad
;
...
@@ -345,7 +326,6 @@ LDAPRDN_rewrite( LDAPRDN rdn, unsigned flags, void *ctx )
...
@@ -345,7 +326,6 @@ LDAPRDN_rewrite( LDAPRDN rdn, unsigned flags, void *ctx )
slap_syntax_transform_func
*
transf
=
NULL
;
slap_syntax_transform_func
*
transf
=
NULL
;
MatchingRule
*
mr
=
NULL
;
MatchingRule
*
mr
=
NULL
;
struct
berval
bv
=
BER_BVNULL
;
struct
berval
bv
=
BER_BVNULL
;
int
do_sort
=
0
;
assert
(
ava
!=
NULL
);
assert
(
ava
!=
NULL
);
...
@@ -445,10 +425,14 @@ LDAPRDN_rewrite( LDAPRDN rdn, unsigned flags, void *ctx )
...
@@ -445,10 +425,14 @@ LDAPRDN_rewrite( LDAPRDN rdn, unsigned flags, void *ctx )
ava
->
la_value
=
bv
;
ava
->
la_value
=
bv
;
ava
->
la_flags
|=
LDAP_AVA_FREE_VALUE
;
ava
->
la_flags
|=
LDAP_AVA_FREE_VALUE
;
}
}
}
rc
=
LDAP_SUCCESS
;
if
(
do_sort
)
AVA_Sort
(
rdn
,
iAVA
);
if
(
do_sort
)
{
rc
=
AVA_Sort
(
rdn
,
iAVA
);
}
}
return
LDAP_SUCCESS
;
return
rc
;
}
}
/*
/*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment