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
David Barchiesi
OpenLDAP
Commits
6a37f1ae
Commit
6a37f1ae
authored
22 years ago
by
Howard Chu
Browse files
Options
Downloads
Patches
Plain Diff
Added ber_flatten2 - uses passed in struct berval, allocates copy or
directly re-uses existing ber buf.
parent
4ab720ee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/lber.h
+6
-0
6 additions, 0 deletions
include/lber.h
libraries/liblber/io.c
+45
-20
45 additions, 20 deletions
libraries/liblber/io.c
with
51 additions
and
20 deletions
include/lber.h
+
6
−
0
View file @
6a37f1ae
...
@@ -469,6 +469,12 @@ ber_flatten LDAP_P((
...
@@ -469,6 +469,12 @@ ber_flatten LDAP_P((
BerElement
*
ber
,
BerElement
*
ber
,
struct
berval
**
bvPtr
));
struct
berval
**
bvPtr
));
LBER_F
(
int
)
ber_flatten2
LDAP_P
((
BerElement
*
ber
,
struct
berval
*
bv
,
int
alloc
));
/*
/*
* LBER ber accessor functions
* LBER ber accessor functions
*/
*/
...
...
This diff is collapsed.
Click to expand it.
libraries/liblber/io.c
+
45
−
20
View file @
6a37f1ae
...
@@ -362,24 +362,21 @@ ber_init( struct berval *bv )
...
@@ -362,24 +362,21 @@ ber_init( struct berval *bv )
/* New C-API ber_flatten routine */
/* New C-API ber_flatten routine */
/* This routine allocates a struct berval whose contents are a BER
/* This routine allocates a struct berval whose contents are a BER
** encoding taken from the ber argument. The bvPtr pointer point
er
s to
** encoding taken from the ber argument. The bvPtr pointer points to
** the returned berval.
** the returned berval.
**
** ber_flatten2 is the same, but uses a struct berval passed by
** the caller. If alloc is 0 the returned bv uses the ber buf directly.
*/
*/
int
ber_flatten
(
int
ber_flatten
2
(
BerElement
*
ber
,
BerElement
*
ber
,
struct
berval
**
bvPtr
)
struct
berval
*
bv
,
int
alloc
)
{
{
struct
berval
*
bv
;
assert
(
bv
!=
NULL
);
assert
(
bvPtr
!=
NULL
);
ber_int_options
.
lbo_valid
=
LBER_INITIALIZED
;
if
(
bvPtr
==
NULL
)
{
ber_int_options
.
lbo_valid
=
LBER_INITIALIZED
;
return
-
1
;
}
bv
=
LBER_MALLOC
(
sizeof
(
struct
berval
)
);
if
(
bv
==
NULL
)
{
if
(
bv
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -393,21 +390,49 @@ int ber_flatten(
...
@@ -393,21 +390,49 @@ int ber_flatten(
/* copy the berval */
/* copy the berval */
ber_len_t
len
=
ber_pvt_ber_write
(
ber
);
ber_len_t
len
=
ber_pvt_ber_write
(
ber
);
bv
->
bv_val
=
(
char
*
)
LBER_MALLOC
(
len
+
1
);
if
(
alloc
)
{
if
(
bv
->
bv_val
==
NULL
)
{
bv
->
bv_val
=
(
char
*
)
LBER_MALLOC
(
len
+
1
);
LBER_FREE
(
bv
);
if
(
bv
->
bv_val
==
NULL
)
{
return
-
1
;
return
-
1
;
}
AC_MEMCPY
(
bv
->
bv_val
,
ber
->
ber_buf
,
len
);
}
else
{
bv
->
bv_val
=
ber
->
ber_buf
;
}
}
AC_MEMCPY
(
bv
->
bv_val
,
ber
->
ber_buf
,
len
);
bv
->
bv_val
[
len
]
=
'\0'
;
bv
->
bv_val
[
len
]
=
'\0'
;
bv
->
bv_len
=
len
;
bv
->
bv_len
=
len
;
}
}
*
bvPtr
=
bv
;
return
0
;
return
0
;
}
}
int
ber_flatten
(
BerElement
*
ber
,
struct
berval
**
bvPtr
)
{
struct
berval
*
bv
;
int
rc
;
assert
(
bvPtr
!=
NULL
);
ber_int_options
.
lbo_valid
=
LBER_INITIALIZED
;
if
(
bvPtr
==
NULL
)
{
return
-
1
;
}
bv
=
LBER_MALLOC
(
sizeof
(
struct
berval
)
);
if
(
bv
==
NULL
)
{
return
-
1
;
}
rc
=
ber_flatten2
(
ber
,
bv
,
1
);
if
(
rc
==
-
1
)
{
LBER_FREE
(
bv
);
}
else
{
*
bvPtr
=
bv
;
}
return
rc
;
}
void
void
ber_reset
(
BerElement
*
ber
,
int
was_writing
)
ber_reset
(
BerElement
*
ber
,
int
was_writing
)
{
{
...
...
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