Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review 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
Christopher Ng
OpenLDAP
Commits
276b5209
Commit
276b5209
authored
23 years ago
by
Howard Chu
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup, added some explanation/comments
parent
bab600ba
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/liblber/decode.c
+21
-1
21 additions, 1 deletion
libraries/liblber/decode.c
with
21 additions
and
1 deletion
libraries/liblber/decode.c
+
21
−
1
View file @
276b5209
...
...
@@ -278,8 +278,13 @@ ber_get_stringb(
return
tag
;
}
/* Definitions for recursive get_string */
enum
bgbvc
{
ChArray
,
BvArray
,
BvVec
};
/* Use this single cookie for state, to keep actual
* stack use to the absolute minimum.
*/
typedef
struct
bgbvr
{
BerElement
*
ber
;
enum
bgbvc
choice
;
...
...
@@ -293,6 +298,10 @@ typedef struct bgbvr {
}
res
;
}
bgbvr
;
/* Recursive get_string, for decoding a vector of strings. The number
* of elements in the vector is limited only by available stack space.
* Each invocation consumes 24 bytes of stack on a 32-bit machine.
*/
ber_tag_t
ber_get_stringbvr
(
bgbvr
*
b
,
int
n
)
{
...
...
@@ -309,7 +318,7 @@ ber_get_stringbvr( bgbvr *b, int n )
*
b
->
res
.
c
=
NULL
;
return
0
;
}
/*
do the allocation
*/
/*
Allocate the result vector
*/
switch
(
b
->
choice
)
{
case
ChArray
:
*
b
->
res
.
c
=
LBER_MALLOC
(
(
n
+
1
)
*
sizeof
(
char
*
));
...
...
@@ -324,9 +333,15 @@ ber_get_stringbvr( bgbvr *b, int n )
(
*
b
->
res
.
bv
)[
n
]
=
NULL
;
break
;
}
/* Did the malloc succeed? */
if
(
*
b
->
res
.
c
==
NULL
)
return
LBER_DEFAULT
;
return
0
;
}
/* Do all local allocs before the recursion. Then there
* cannot possibly be any failures on the return trip.
*/
if
(
b
->
choice
==
BvVec
)
bvp
=
LBER_MALLOC
(
sizeof
(
struct
berval
));
...
...
@@ -336,6 +351,7 @@ ber_get_stringbvr( bgbvr *b, int n )
}
b
->
tag
=
ber_get_stringbvr
(
b
,
n
+
1
);
if
(
b
->
tag
==
0
)
{
/* store my result */
...
...
@@ -352,6 +368,9 @@ ber_get_stringbvr( bgbvr *b, int n )
break
;
}
}
else
{
/* Failure will propagate up and free in reverse
* order, which is actually ideal.
*/
if
(
bvp
)
LBER_FREE
(
bvp
);
LBER_FREE
(
bv
.
bv_val
);
}
...
...
@@ -549,6 +568,7 @@ ber_next_element(
}
/* Hopefully no one sends vectors with more elements than this */
/* Don't define this! ber_get_stringbvr works much much better! */
/* #define TMP_SLOTS 1024 */
/* VARARGS */
...
...
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