Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
James Lowden
OpenLDAP
Commits
4458f258
Commit
4458f258
authored
16 years ago
by
Quanah Gibson-Mount
Browse files
Options
Downloads
Patches
Plain Diff
Use memctx more consistently
parent
5a27f966
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/liblunicode/ucstr.c
+30
-21
30 additions, 21 deletions
libraries/liblunicode/ucstr.c
with
30 additions
and
21 deletions
libraries/liblunicode/ucstr.c
+
30
−
21
View file @
4458f258
...
@@ -128,7 +128,12 @@ struct berval * UTF8bvnormalize(
...
@@ -128,7 +128,12 @@ struct berval * UTF8bvnormalize(
if
(
len
==
0
)
{
if
(
len
==
0
)
{
return
ber_dupbv_x
(
newbv
,
bv
,
ctx
);
return
ber_dupbv_x
(
newbv
,
bv
,
ctx
);
}
}
if
(
!
newbv
)
{
newbv
=
ber_memalloc_x
(
sizeof
(
struct
berval
),
ctx
);
if
(
!
newbv
)
return
NULL
;
}
/* Should first check to see if string is already in proper
/* Should first check to see if string is already in proper
* normalized form. This is almost as time consuming as
* normalized form. This is almost as time consuming as
* the normalization though.
* the normalization though.
...
@@ -138,7 +143,7 @@ struct berval * UTF8bvnormalize(
...
@@ -138,7 +143,7 @@ struct berval * UTF8bvnormalize(
if
(
LDAP_UTF8_ISASCII
(
s
)
)
{
if
(
LDAP_UTF8_ISASCII
(
s
)
)
{
if
(
casefold
)
{
if
(
casefold
)
{
outsize
=
len
+
7
;
outsize
=
len
+
7
;
out
=
(
char
*
)
malloc
(
outsize
);
out
=
(
char
*
)
ber_me
malloc
_x
(
outsize
,
ctx
);
if
(
out
==
NULL
)
{
if
(
out
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -150,7 +155,9 @@ struct berval * UTF8bvnormalize(
...
@@ -150,7 +155,9 @@ struct berval * UTF8bvnormalize(
if
(
i
==
len
)
{
if
(
i
==
len
)
{
out
[
outpos
++
]
=
TOLOWER
(
s
[
len
-
1
]
);
out
[
outpos
++
]
=
TOLOWER
(
s
[
len
-
1
]
);
out
[
outpos
]
=
'\0'
;
out
[
outpos
]
=
'\0'
;
return
ber_str2bv
(
out
,
outpos
,
0
,
newbv
);
newbv
->
bv_val
=
out
;
newbv
->
bv_len
=
outpos
;
return
newbv
;
}
}
}
else
{
}
else
{
for
(
i
=
1
;
(
i
<
len
)
&&
LDAP_UTF8_ISASCII
(
s
+
i
);
i
++
)
{
for
(
i
=
1
;
(
i
<
len
)
&&
LDAP_UTF8_ISASCII
(
s
+
i
);
i
++
)
{
...
@@ -162,7 +169,7 @@ struct berval * UTF8bvnormalize(
...
@@ -162,7 +169,7 @@ struct berval * UTF8bvnormalize(
}
}
outsize
=
len
+
7
;
outsize
=
len
+
7
;
out
=
(
char
*
)
malloc
(
outsize
);
out
=
(
char
*
)
ber_me
malloc
_x
(
outsize
,
ctx
);
if
(
out
==
NULL
)
{
if
(
out
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -171,7 +178,7 @@ struct berval * UTF8bvnormalize(
...
@@ -171,7 +178,7 @@ struct berval * UTF8bvnormalize(
}
}
}
else
{
}
else
{
outsize
=
len
+
7
;
outsize
=
len
+
7
;
out
=
(
char
*
)
malloc
(
outsize
);
out
=
(
char
*
)
ber_me
malloc
_x
(
outsize
,
ctx
);
if
(
out
==
NULL
)
{
if
(
out
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -179,9 +186,9 @@ struct berval * UTF8bvnormalize(
...
@@ -179,9 +186,9 @@ struct berval * UTF8bvnormalize(
i
=
0
;
i
=
0
;
}
}
p
=
ucs
=
malloc
(
len
*
sizeof
(
*
ucs
)
);
p
=
ucs
=
ber_me
malloc
_x
(
len
*
sizeof
(
*
ucs
)
,
ctx
);
if
(
ucs
==
NULL
)
{
if
(
ucs
==
NULL
)
{
free
(
out
);
ber_mem
free
_x
(
out
,
ctx
);
return
NULL
;
return
NULL
;
}
}
...
@@ -198,8 +205,8 @@ struct berval * UTF8bvnormalize(
...
@@ -198,8 +205,8 @@ struct berval * UTF8bvnormalize(
while
(
i
<
len
)
{
while
(
i
<
len
)
{
clen
=
LDAP_UTF8_CHARLEN2
(
s
+
i
,
clen
);
clen
=
LDAP_UTF8_CHARLEN2
(
s
+
i
,
clen
);
if
(
clen
==
0
)
{
if
(
clen
==
0
)
{
free
(
ucs
);
ber_mem
free
_x
(
ucs
,
ctx
);
free
(
out
);
ber_mem
free
_x
(
out
,
ctx
);
return
NULL
;
return
NULL
;
}
}
if
(
clen
==
1
)
{
if
(
clen
==
1
)
{
...
@@ -210,8 +217,8 @@ struct berval * UTF8bvnormalize(
...
@@ -210,8 +217,8 @@ struct berval * UTF8bvnormalize(
i
++
;
i
++
;
for
(
j
=
1
;
j
<
clen
;
j
++
)
{
for
(
j
=
1
;
j
<
clen
;
j
++
)
{
if
(
(
s
[
i
]
&
0xc0
)
!=
0x80
)
{
if
(
(
s
[
i
]
&
0xc0
)
!=
0x80
)
{
free
(
ucs
);
ber_mem
free
_x
(
ucs
,
ctx
);
free
(
out
);
ber_mem
free
_x
(
out
,
ctx
);
return
NULL
;
return
NULL
;
}
}
*
p
<<=
6
;
*
p
<<=
6
;
...
@@ -239,11 +246,11 @@ struct berval * UTF8bvnormalize(
...
@@ -239,11 +246,11 @@ struct berval * UTF8bvnormalize(
6 bytes and terminator */
6 bytes and terminator */
if
(
outsize
-
outpos
<
7
)
{
if
(
outsize
-
outpos
<
7
)
{
outsize
=
ucsoutlen
-
j
+
outpos
+
6
;
outsize
=
ucsoutlen
-
j
+
outpos
+
6
;
outtmp
=
(
char
*
)
realloc
(
out
,
outsize
);
outtmp
=
(
char
*
)
ber_mem
realloc
_x
(
out
,
outsize
,
ctx
);
if
(
outtmp
==
NULL
)
{
if
(
outtmp
==
NULL
)
{
free
(
out
);
ber_memfree_x
(
ucsout
,
ctx
);
free
(
ucs
);
ber_mem
free
_x
(
ucs
,
ctx
);
free
(
ucsout
);
ber_memfree_x
(
out
,
ctx
);
return
NULL
;
return
NULL
;
}
}
out
=
outtmp
;
out
=
outtmp
;
...
@@ -252,7 +259,7 @@ struct berval * UTF8bvnormalize(
...
@@ -252,7 +259,7 @@ struct berval * UTF8bvnormalize(
}
}
}
}
free
(
ucsout
);
ber_mem
free
_x
(
ucsout
,
ctx
);
ucsout
=
NULL
;
ucsout
=
NULL
;
if
(
i
==
len
)
{
if
(
i
==
len
)
{
...
@@ -264,10 +271,10 @@ struct berval * UTF8bvnormalize(
...
@@ -264,10 +271,10 @@ struct berval * UTF8bvnormalize(
/* Allocate more space in out if necessary */
/* Allocate more space in out if necessary */
if
(
len
-
i
>=
outsize
-
outpos
)
{
if
(
len
-
i
>=
outsize
-
outpos
)
{
outsize
+=
1
+
((
len
-
i
)
-
(
outsize
-
outpos
));
outsize
+=
1
+
((
len
-
i
)
-
(
outsize
-
outpos
));
outtmp
=
(
char
*
)
realloc
(
out
,
outsize
);
outtmp
=
(
char
*
)
ber_mem
realloc
_x
(
out
,
outsize
,
ctx
);
if
(
outtmp
==
NULL
)
{
if
(
outtmp
==
NULL
)
{
free
(
out
);
ber_memfree_x
(
ucs
,
ctx
);
free
(
ucs
);
ber_memfree_x
(
out
,
ctx
);
return
NULL
;
return
NULL
;
}
}
out
=
outtmp
;
out
=
outtmp
;
...
@@ -288,9 +295,11 @@ struct berval * UTF8bvnormalize(
...
@@ -288,9 +295,11 @@ struct berval * UTF8bvnormalize(
p
=
ucs
+
1
;
p
=
ucs
+
1
;
}
}
free
(
ucs
);
ber_mem
free
_x
(
ucs
,
ctx
);
out
[
outpos
]
=
'\0'
;
out
[
outpos
]
=
'\0'
;
return
ber_str2bv
(
out
,
outpos
,
0
,
newbv
);
newbv
->
bv_val
=
out
;
newbv
->
bv_len
=
outpos
;
return
newbv
;
}
}
/* compare UTF8-strings, optionally ignore casing */
/* compare UTF8-strings, optionally ignore casing */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment