Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
baaa24fa
Commit
baaa24fa
authored
Sep 29, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added stack checking into ber_skip_length also
parent
c500b3e1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
10 deletions
+32
-10
skeletons/ber_decoder.c
skeletons/ber_decoder.c
+4
-2
skeletons/ber_tlv_length.c
skeletons/ber_tlv_length.c
+19
-2
skeletons/ber_tlv_length.h
skeletons/ber_tlv_length.h
+4
-1
skeletons/constr_CHOICE.c
skeletons/constr_CHOICE.c
+1
-1
skeletons/constr_SEQUENCE.c
skeletons/constr_SEQUENCE.c
+2
-2
skeletons/constr_SET.c
skeletons/constr_SET.c
+2
-2
No files found.
skeletons/ber_decoder.c
View file @
baaa24fa
...
@@ -71,10 +71,12 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx,
...
@@ -71,10 +71,12 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx,
int
step
=
opt_ctx
?
opt_ctx
->
step
:
0
;
/* Where we left previously */
int
step
=
opt_ctx
?
opt_ctx
->
step
:
0
;
/* Where we left previously */
int
tagno
;
int
tagno
;
/*
* Make sure we didn't exceed the maximum stack size.
*/
if
(
opt_codec_ctx
&&
opt_codec_ctx
->
max_stack_size
)
{
if
(
opt_codec_ctx
&&
opt_codec_ctx
->
max_stack_size
)
{
ptrdiff_t
usedstack
=
((
char
*
)
opt_codec_ctx
-
(
char
*
)
&
size
);
ptrdiff_t
usedstack
=
((
char
*
)
opt_codec_ctx
-
(
char
*
)
&
size
);
/* do not change the semantics:
/* double negative is required to avoid int wrap-around */
* double negative is required to avoid int wrap-around */
if
(
usedstack
>
0
)
usedstack
=
-
usedstack
;
if
(
usedstack
>
0
)
usedstack
=
-
usedstack
;
ASN_DEBUG
(
"Current stack size %ld"
,
-
(
long
)
usedstack
);
ASN_DEBUG
(
"Current stack size %ld"
,
-
(
long
)
usedstack
);
if
(
usedstack
<
-
(
ptrdiff_t
)
opt_codec_ctx
->
max_stack_size
)
{
if
(
usedstack
<
-
(
ptrdiff_t
)
opt_codec_ctx
->
max_stack_size
)
{
...
...
skeletons/ber_tlv_length.c
View file @
baaa24fa
...
@@ -74,12 +74,28 @@ ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
...
@@ -74,12 +74,28 @@ ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
}
}
ssize_t
ssize_t
ber_skip_length
(
int
_is_constructed
,
void
*
ptr
,
size_t
size
)
{
ber_skip_length
(
asn_codec_ctx_t
*
opt_codec_ctx
,
int
_is_constructed
,
void
*
ptr
,
size_t
size
)
{
ber_tlv_len_t
vlen
;
/* Length of V in TLV */
ber_tlv_len_t
vlen
;
/* Length of V in TLV */
ssize_t
tl
;
/* Length of L in TLV */
ssize_t
tl
;
/* Length of L in TLV */
ssize_t
ll
;
/* Length of L in TLV */
ssize_t
ll
;
/* Length of L in TLV */
size_t
skip
;
size_t
skip
;
/*
* Make sure we didn't exceed the maximum stack size.
*/
if
(
opt_codec_ctx
&&
opt_codec_ctx
->
max_stack_size
)
{
ptrdiff_t
usedstack
=
((
char
*
)
opt_codec_ctx
-
(
char
*
)
&
size
);
/* double negative is required to avoid int wrap-around */
if
(
usedstack
>
0
)
usedstack
=
-
usedstack
;
ASN_DEBUG
(
"Current stack size %ld"
,
-
(
long
)
usedstack
);
if
(
usedstack
<
-
(
ptrdiff_t
)
opt_codec_ctx
->
max_stack_size
)
{
ASN_DEBUG
(
"Stack limit %ld reached"
,
(
long
)
opt_codec_ctx
->
max_stack_size
);
return
-
1
;
}
}
/*
/*
* Determine the size of L in TLV.
* Determine the size of L in TLV.
*/
*/
...
@@ -107,7 +123,8 @@ ber_skip_length(int _is_constructed, void *ptr, size_t size) {
...
@@ -107,7 +123,8 @@ ber_skip_length(int _is_constructed, void *ptr, size_t size) {
tl
=
ber_fetch_tag
(
ptr
,
size
,
&
tag
);
tl
=
ber_fetch_tag
(
ptr
,
size
,
&
tag
);
if
(
tl
<=
0
)
return
tl
;
if
(
tl
<=
0
)
return
tl
;
ll
=
ber_skip_length
(
BER_TLV_CONSTRUCTED
(
ptr
),
ll
=
ber_skip_length
(
opt_codec_ctx
,
BER_TLV_CONSTRUCTED
(
ptr
),
((
char
*
)
ptr
)
+
tl
,
size
-
tl
);
((
char
*
)
ptr
)
+
tl
,
size
-
tl
);
if
(
ll
<=
0
)
return
ll
;
if
(
ll
<=
0
)
return
ll
;
...
...
skeletons/ber_tlv_length.h
View file @
baaa24fa
...
@@ -27,7 +27,10 @@ ssize_t ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
...
@@ -27,7 +27,10 @@ ssize_t ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
* RETURN VALUES:
* RETURN VALUES:
* Standard {-1,0,>0} convention.
* Standard {-1,0,>0} convention.
*/
*/
ssize_t
ber_skip_length
(
int
_is_constructed
,
void
*
bufptr
,
size_t
size
);
struct
asn_codec_ctx_s
;
/* Forward declaration */
ssize_t
ber_skip_length
(
struct
asn_codec_ctx_s
*
opt_codec_ctx
,
/* optional context */
int
_is_constructed
,
void
*
bufptr
,
size_t
size
);
/*
/*
* This function serializes the length (L from TLV) in DER format.
* This function serializes the length (L from TLV) in DER format.
...
...
skeletons/constr_CHOICE.c
View file @
baaa24fa
...
@@ -209,7 +209,7 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -209,7 +209,7 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ASN_DEBUG
(
"Skipping unknown tag %s"
,
ASN_DEBUG
(
"Skipping unknown tag %s"
,
ber_tlv_tag_string
(
tlv_tag
));
ber_tlv_tag_string
(
tlv_tag
));
skip
=
ber_skip_length
(
skip
=
ber_skip_length
(
opt_codec_ctx
,
BER_TLV_CONSTRUCTED
(
ptr
),
BER_TLV_CONSTRUCTED
(
ptr
),
(
char
*
)
ptr
+
tag_len
,
LEFT
-
tag_len
);
(
char
*
)
ptr
+
tag_len
,
LEFT
-
tag_len
);
...
...
skeletons/constr_SEQUENCE.c
View file @
baaa24fa
...
@@ -352,7 +352,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -352,7 +352,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/* Skip this tag */
/* Skip this tag */
ssize_t
skip
;
ssize_t
skip
;
skip
=
ber_skip_length
(
skip
=
ber_skip_length
(
opt_codec_ctx
,
BER_TLV_CONSTRUCTED
(
ptr
),
BER_TLV_CONSTRUCTED
(
ptr
),
(
char
*
)
ptr
+
tag_len
,
LEFT
-
tag_len
);
(
char
*
)
ptr
+
tag_len
,
LEFT
-
tag_len
);
ASN_DEBUG
(
"Skip length %d in %s"
,
ASN_DEBUG
(
"Skip length %d in %s"
,
...
@@ -474,7 +474,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -474,7 +474,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
RETURN
(
RC_FAIL
);
RETURN
(
RC_FAIL
);
}
}
ll
=
ber_skip_length
(
ll
=
ber_skip_length
(
opt_codec_ctx
,
BER_TLV_CONSTRUCTED
(
ptr
),
BER_TLV_CONSTRUCTED
(
ptr
),
(
char
*
)
ptr
+
tl
,
LEFT
-
tl
);
(
char
*
)
ptr
+
tl
,
LEFT
-
tl
);
switch
(
ll
)
{
switch
(
ll
)
{
...
...
skeletons/constr_SET.c
View file @
baaa24fa
...
@@ -259,7 +259,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -259,7 +259,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ASN_DEBUG
(
"Skipping unknown tag %s"
,
ASN_DEBUG
(
"Skipping unknown tag %s"
,
ber_tlv_tag_string
(
tlv_tag
));
ber_tlv_tag_string
(
tlv_tag
));
skip
=
ber_skip_length
(
skip
=
ber_skip_length
(
opt_codec_ctx
,
BER_TLV_CONSTRUCTED
(
ptr
),
BER_TLV_CONSTRUCTED
(
ptr
),
(
char
*
)
ptr
+
tag_len
,
LEFT
-
tag_len
);
(
char
*
)
ptr
+
tag_len
,
LEFT
-
tag_len
);
...
@@ -381,7 +381,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -381,7 +381,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
RETURN
(
RC_FAIL
);
RETURN
(
RC_FAIL
);
}
}
ll
=
ber_skip_length
(
ll
=
ber_skip_length
(
opt_codec_ctx
,
BER_TLV_CONSTRUCTED
(
ptr
),
BER_TLV_CONSTRUCTED
(
ptr
),
(
char
*
)
ptr
+
tl
,
LEFT
-
tl
);
(
char
*
)
ptr
+
tl
,
LEFT
-
tl
);
switch
(
ll
)
{
switch
(
ll
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment