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
3a5e383d
Commit
3a5e383d
authored
26 years ago
by
Kurt Zeilenga
Browse files
Options
Downloads
Patches
Plain Diff
Add draft-ietf-ldapext-ldap-c-api-01 routines ber_init()
and ber_flatten() to the -llber.
parent
5d2accea
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/lber.h
+2
-2
2 additions, 2 deletions
include/lber.h
libraries/liblber/decode.c
+51
-4
51 additions, 4 deletions
libraries/liblber/decode.c
libraries/liblber/io.c
+69
-1
69 additions, 1 deletion
libraries/liblber/io.c
with
122 additions
and
7 deletions
include/lber.h
+
2
−
2
View file @
3a5e383d
...
...
@@ -40,7 +40,7 @@ LDAP_BEGIN_DECL
*/
#define LBER_ERROR 0xffffffffL
#define LBER_DEFAULT 0xffffffffL
#define LBER_END_SEQORSET 0xfffffffeL
/*
#define LBER_END_SEQORSET 0xfffffffeL
*//* no part of LDAP C-API */
/* general BER types we know about */
#define LBER_BOOLEAN 0x01L
...
...
@@ -168,7 +168,7 @@ LDAP_F void ber_init_w_nullc LDAP_P(( BerElement *ber, int options ));
LDAP_F
void
ber_reset
LDAP_P
((
BerElement
*
ber
,
int
was_writing
));
/*
* LDAP
v3 routines (not yet implemented)
* LDAP
draft-ietf-ldapext-ldap-c-api-01 routines
*/
LDAP_F
BerElement
*
ber_init
LDAP_P
((
struct
berval
*
bv
));
LDAP_F
int
ber_flatten
LDAP_P
((
BerElement
*
ber
,
struct
berval
**
bvPtr
));
...
...
This diff is collapsed.
Click to expand it.
libraries/liblber/decode.c
+
51
−
4
View file @
3a5e383d
...
...
@@ -344,7 +344,11 @@ ber_first_element( BerElement *ber, unsigned long *len, char **last )
*
last
=
ber
->
ber_ptr
+
*
len
;
if
(
*
last
==
ber
->
ber_ptr
)
{
#ifdef LBER_END_SEQORSET
return
(
LBER_END_SEQORSET
);
#else
return
(
LBER_DEFAULT
);
#endif
}
return
(
ber_peek_tag
(
ber
,
len
)
);
...
...
@@ -354,7 +358,11 @@ unsigned long
ber_next_element
(
BerElement
*
ber
,
unsigned
long
*
len
,
char
*
last
)
{
if
(
ber
->
ber_ptr
==
last
)
{
#ifdef LBER_END_SEQORSET
return
(
LBER_END_SEQORSET
);
#else
return
(
LBER_DEFAULT
);
#endif
}
return
(
ber_peek_tag
(
ber
,
len
)
);
...
...
@@ -462,8 +470,13 @@ va_dcl
*
sss
=
NULL
;
j
=
0
;
for
(
tag
=
ber_first_element
(
ber
,
&
len
,
&
last
);
tag
!=
LBER_DEFAULT
&&
rc
!=
LBER_DEFAULT
;
tag
=
ber_next_element
(
ber
,
&
len
,
last
)
)
{
tag
!=
LBER_DEFAULT
&&
#ifdef LDAP_END_SEQORSET
tag
!=
LBER_END_SEQORSET
&&
#endif
rc
!=
LBER_DEFAULT
;
tag
=
ber_next_element
(
ber
,
&
len
,
last
)
)
{
if
(
*
sss
==
NULL
)
{
*
sss
=
(
char
**
)
malloc
(
2
*
sizeof
(
char
*
)
);
...
...
@@ -474,6 +487,13 @@ va_dcl
rc
=
ber_get_stringa
(
ber
,
&
((
*
sss
)[
j
])
);
j
++
;
}
#ifdef LDAP_END_SEQORSET
if
(
rc
!=
LBER_DEFAULT
&&
tag
!=
LBER_END_SEQORSET
)
{
rc
=
LBER_DEFAULT
;
}
#endif
if
(
j
>
0
)
(
*
sss
)[
j
]
=
NULL
;
break
;
...
...
@@ -483,8 +503,13 @@ va_dcl
*
bv
=
NULL
;
j
=
0
;
for
(
tag
=
ber_first_element
(
ber
,
&
len
,
&
last
);
tag
!=
LBER_DEFAULT
&&
rc
!=
LBER_DEFAULT
;
tag
=
ber_next_element
(
ber
,
&
len
,
last
)
)
{
tag
!=
LBER_DEFAULT
&&
#ifdef LDAP_END_SEQORSET
tag
!=
LBER_END_SEQORSET
&&
#endif
rc
!=
LBER_DEFAULT
;
tag
=
ber_next_element
(
ber
,
&
len
,
last
)
)
{
if
(
*
bv
==
NULL
)
{
*
bv
=
(
struct
berval
**
)
malloc
(
2
*
sizeof
(
struct
berval
*
)
);
...
...
@@ -495,6 +520,13 @@ va_dcl
rc
=
ber_get_stringal
(
ber
,
&
((
*
bv
)[
j
])
);
j
++
;
}
#ifdef LDAP_END_SEQORSET
if
(
rc
!=
LBER_DEFAULT
&&
tag
!=
LBER_END_SEQORSET
)
{
rc
=
LBER_DEFAULT
;
}
#endif
if
(
j
>
0
)
(
*
bv
)[
j
]
=
NULL
;
break
;
...
...
@@ -532,6 +564,9 @@ va_dcl
void
ber_bvfree
(
struct
berval
*
bv
)
{
#ifdef LBER_ASSERT
assert
(
bv
!=
NULL
);
/* bv damn better point to something */
#endif
if
(
bv
->
bv_val
!=
NULL
)
free
(
bv
->
bv_val
);
free
(
(
char
*
)
bv
);
...
...
@@ -542,6 +577,9 @@ ber_bvecfree( struct berval **bv )
{
int
i
;
#ifdef LBER_ASSERT
assert
(
bv
!=
NULL
);
/* bv damn better point to something */
#endif
for
(
i
=
0
;
bv
[
i
]
!=
NULL
;
i
++
)
ber_bvfree
(
bv
[
i
]
);
free
(
(
char
*
)
bv
);
...
...
@@ -556,9 +594,18 @@ ber_bvdup( struct berval *bv )
==
NULL
)
{
return
(
NULL
);
}
if
(
bv
->
bv_val
==
NULL
)
{
new
->
bv_val
=
NULL
;
new
->
bv_len
=
0
;
return
(
new
);
}
if
(
(
new
->
bv_val
=
(
char
*
)
malloc
(
bv
->
bv_len
+
1
))
==
NULL
)
{
free
(
new
);
return
(
NULL
);
}
SAFEMEMCPY
(
new
->
bv_val
,
bv
->
bv_val
,
(
size_t
)
bv
->
bv_len
);
new
->
bv_val
[
bv
->
bv_len
]
=
'\0'
;
new
->
bv_len
=
bv
->
bv_len
;
...
...
This diff is collapsed.
Click to expand it.
libraries/liblber/io.c
+
69
−
1
View file @
3a5e383d
...
...
@@ -365,6 +365,7 @@ ber_dup( BerElement *ber )
}
/* OLD U-Mich ber_init() */
void
ber_init_w_nullc
(
BerElement
*
ber
,
int
options
)
{
...
...
@@ -373,12 +374,79 @@ ber_init_w_nullc( BerElement *ber, int options )
ber
->
ber_options
=
(
char
)
options
;
}
/* New C-API ber_init() */
/* This function constructs a BerElement containing a copy
** of the data in the bv argument.
*/
BerElement
*
ber_init
(
struct
berval
*
bv
)
{
return
(
NULL
);
BerElement
*
ber
;
if
(
bv
==
NULL
)
{
return
NULL
;
}
ber
=
ber_alloc_t
(
0
);
if
(
ber
==
NULLBER
)
{
/* allocation failed */
return
(
NULL
);
}
/* copy the data */
if
(
(
ber_write
(
ber
,
bv
->
bv_val
,
bv
->
bv_len
,
0
))
!=
bv
->
bv_len
)
{
/* write failed, so free and return NULL */
ber_free
(
ber
,
1
);
return
(
NULL
);
}
ber_reset
(
ber
,
1
);
/* reset the pointer to the start of the buffer */
return
(
ber
);
}
/* New C-API ber_flatten routine */
/* This routine allocates a struct berval whose contents are a BER
** encoding taken from the ber argument. The bvPtr pointer pointers to
** the returned berval.
*/
int
ber_flatten
(
BerElement
*
ber
,
struct
berval
**
bvPtr
)
{
struct
berval
*
bv
;
if
(
bvPtr
==
NULL
)
{
return
(
-
1
);
}
if
(
(
bv
=
malloc
(
sizeof
(
struct
berval
)))
==
NULL
)
{
return
(
-
1
);
}
if
(
ber
==
NULL
)
{
/* ber is null, create an empty berval */
bv
->
bv_val
=
NULL
;
bv
->
bv_len
=
0
;
}
else
{
/* copy the berval */
ptrdiff_t
len
=
ber
->
ber_ptr
-
ber
->
ber_buf
;
if
(
(
bv
->
bv_val
=
(
char
*
)
malloc
(
len
+
1
))
==
NULL
)
{
ber_bvfree
(
bv
);
return
(
-
1
);
}
SAFEMEMCPY
(
bv
->
bv_val
,
ber
->
ber_buf
,
(
size_t
)
len
);
bv
->
bv_val
[
len
]
=
'\0'
;
bv
->
bv_len
=
len
;
}
*
bvPtr
=
bv
;
return
(
0
);
}
void
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