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
Dragoș Haiduc
OpenLDAP
Commits
b213588f
Commit
b213588f
authored
18 years ago
by
Howard Chu
Browse files
Options
Downloads
Patches
Plain Diff
Add options for ber_get_stringbv() to omit NUL-terminator, to allow
non-destructive in-place parsing
parent
f2a02b90
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
+4
-1
4 additions, 1 deletion
include/lber.h
libraries/liblber/decode.c
+15
-13
15 additions, 13 deletions
libraries/liblber/decode.c
with
19 additions
and
14 deletions
include/lber.h
+
4
−
1
View file @
b213588f
...
...
@@ -267,11 +267,14 @@ ber_get_stringb LDAP_P((
char
*
buf
,
ber_len_t
*
len
));
#define LBER_BV_ALLOC 0x01
/* allocate/copy result, otherwise in-place */
#define LBER_BV_NOTERM 0x02
/* omit NUL-terminator if parsing in-place */
LBER_F
(
ber_tag_t
)
ber_get_stringbv
LDAP_P
((
BerElement
*
ber
,
struct
berval
*
bv
,
int
alloc
));
int
options
));
LBER_F
(
ber_tag_t
)
ber_get_stringa
LDAP_P
((
...
...
This diff is collapsed.
Click to expand it.
libraries/liblber/decode.c
+
15
−
13
View file @
b213588f
...
...
@@ -471,7 +471,7 @@ nomem:
}
ber_tag_t
ber_get_stringbv
(
BerElement
*
ber
,
struct
berval
*
bv
,
int
alloc
)
ber_get_stringbv
(
BerElement
*
ber
,
struct
berval
*
bv
,
int
option
)
{
ber_tag_t
tag
;
...
...
@@ -489,7 +489,7 @@ ber_get_stringbv( BerElement *ber, struct berval *bv, int alloc )
return
LBER_DEFAULT
;
}
if
(
alloc
)
{
if
(
option
&
LBER_BV_ALLOC
)
{
bv
->
bv_val
=
(
char
*
)
ber_memalloc_x
(
bv
->
bv_len
+
1
,
ber
->
ber_memctx
);
if
(
bv
->
bv_val
==
NULL
)
{
...
...
@@ -508,13 +508,14 @@ ber_get_stringbv( BerElement *ber, struct berval *bv, int alloc )
ber
->
ber_ptr
+=
bv
->
bv_len
;
}
ber
->
ber_tag
=
*
(
unsigned
char
*
)
ber
->
ber_ptr
;
bv
->
bv_val
[
bv
->
bv_len
]
=
'\0'
;
if
(
!
(
option
&
LBER_BV_NOTERM
))
bv
->
bv_val
[
bv
->
bv_len
]
=
'\0'
;
return
tag
;
}
ber_tag_t
ber_get_stringbv_null
(
BerElement
*
ber
,
struct
berval
*
bv
,
int
alloc
)
ber_get_stringbv_null
(
BerElement
*
ber
,
struct
berval
*
bv
,
int
option
)
{
ber_tag_t
tag
;
...
...
@@ -538,7 +539,7 @@ ber_get_stringbv_null( BerElement *ber, struct berval *bv, int alloc )
return
tag
;
}
if
(
alloc
)
{
if
(
option
&
LBER_BV_ALLOC
)
{
bv
->
bv_val
=
(
char
*
)
ber_memalloc_x
(
bv
->
bv_len
+
1
,
ber
->
ber_memctx
);
if
(
bv
->
bv_val
==
NULL
)
{
...
...
@@ -557,7 +558,8 @@ ber_get_stringbv_null( BerElement *ber, struct berval *bv, int alloc )
ber
->
ber_ptr
+=
bv
->
bv_len
;
}
ber
->
ber_tag
=
*
(
unsigned
char
*
)
ber
->
ber_ptr
;
bv
->
bv_val
[
bv
->
bv_len
]
=
'\0'
;
if
(
!
(
option
&
LBER_BV_NOTERM
))
bv
->
bv_val
[
bv
->
bv_len
]
=
'\0'
;
return
tag
;
}
...
...
@@ -570,7 +572,7 @@ ber_get_stringa( BerElement *ber, char **buf )
assert
(
buf
!=
NULL
);
tag
=
ber_get_stringbv
(
ber
,
&
bv
,
1
);
tag
=
ber_get_stringbv
(
ber
,
&
bv
,
LBER_BV_ALLOC
);
*
buf
=
bv
.
bv_val
;
return
tag
;
...
...
@@ -584,7 +586,7 @@ ber_get_stringa_null( BerElement *ber, char **buf )
assert
(
buf
!=
NULL
);
tag
=
ber_get_stringbv_null
(
ber
,
&
bv
,
1
);
tag
=
ber_get_stringbv_null
(
ber
,
&
bv
,
LBER_BV_ALLOC
);
*
buf
=
bv
.
bv_val
;
return
tag
;
...
...
@@ -604,7 +606,7 @@ ber_get_stringal( BerElement *ber, struct berval **bv )
return
LBER_DEFAULT
;
}
tag
=
ber_get_stringbv
(
ber
,
*
bv
,
1
);
tag
=
ber_get_stringbv
(
ber
,
*
bv
,
LBER_BV_ALLOC
);
if
(
tag
==
LBER_DEFAULT
)
{
LBER_FREE
(
*
bv
);
*
bv
=
NULL
;
...
...
@@ -845,7 +847,7 @@ ber_scanf ( BerElement *ber,
case
'o'
:
/* octet string in a supplied berval */
bval
=
va_arg
(
ap
,
struct
berval
*
);
rc
=
ber_get_stringbv
(
ber
,
bval
,
1
);
rc
=
ber_get_stringbv
(
ber
,
bval
,
LBER_BV_ALLOC
);
break
;
case
'O'
:
/* octet string - allocate & include length */
...
...
@@ -874,7 +876,7 @@ ber_scanf ( BerElement *ber,
bgbvr
cookie
=
{
ChArray
};
cookie
.
ber
=
ber
;
cookie
.
res
.
c
=
va_arg
(
ap
,
char
***
);
cookie
.
alloc
=
1
;
cookie
.
alloc
=
LBER_BV_ALLOC
;
rc
=
ber_get_stringbvl
(
&
cookie
,
NULL
);
break
;
}
...
...
@@ -884,7 +886,7 @@ ber_scanf ( BerElement *ber,
bgbvr
cookie
=
{
BvVec
};
cookie
.
ber
=
ber
;
cookie
.
res
.
bv
=
va_arg
(
ap
,
struct
berval
***
);
cookie
.
alloc
=
1
;
cookie
.
alloc
=
LBER_BV_ALLOC
;
rc
=
ber_get_stringbvl
(
&
cookie
,
NULL
);
break
;
}
...
...
@@ -894,7 +896,7 @@ ber_scanf ( BerElement *ber,
bgbvr
cookie
=
{
BvArray
};
cookie
.
ber
=
ber
;
cookie
.
res
.
ba
=
va_arg
(
ap
,
struct
berval
**
);
cookie
.
alloc
=
1
;
cookie
.
alloc
=
LBER_BV_ALLOC
;
rc
=
ber_get_stringbvl
(
&
cookie
,
NULL
);
break
;
}
...
...
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