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
07f388cf
Commit
07f388cf
authored
Oct 11, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed explicitly tagged ANY type handling
parent
e560f4cc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
27 deletions
+36
-27
ChangeLog
ChangeLog
+3
-1
libasn1fix/asn1fix_constr.c
libasn1fix/asn1fix_constr.c
+5
-11
skeletons/OCTET_STRING.c
skeletons/OCTET_STRING.c
+28
-15
No files found.
ChangeLog
View file @
07f388cf
0.9.7: 2004-Oct-
04
0.9.7: 2004-Oct-
11
* Finished CANONICAL-XER implementation by adding SET and SET OF
* Finished CANONICAL-XER implementation by adding SET and SET OF
canonical ordering support.
canonical ordering support.
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
* Fixed SEQUENCE dealing with premature termination of the
* Fixed SEQUENCE dealing with premature termination of the
optionals-laden indefinite length structure. The code was previously
optionals-laden indefinite length structure. The code was previously
refusing to parse such structures.
refusing to parse such structures.
* Fixed explicitly tagged ANY type encoding and decoding
(Severity: medium, Secruity impact: low).
* Fixed CHOICE code spin when indefinite length structures appear
* Fixed CHOICE code spin when indefinite length structures appear
in the extensions (Severity: medium, Security impact: medium).
in the extensions (Severity: medium, Security impact: medium).
Reported by <siden@ul-gsm.ru>.
Reported by <siden@ul-gsm.ru>.
...
...
libasn1fix/asn1fix_constr.c
View file @
07f388cf
...
@@ -250,21 +250,15 @@ asn1f_fix_constr_tag(arg_t *arg, int fix_top_level) {
...
@@ -250,21 +250,15 @@ asn1f_fix_constr_tag(arg_t *arg, int fix_top_level) {
static
int
static
int
_asn1f_fix_type_tag
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
_asn1f_fix_type_tag
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
int
must_explicit
=
_asn1f_check_if_tag_must_be_explicit
(
arg
,
expr
);
int
must_explicit
=
_asn1f_check_if_tag_must_be_explicit
(
arg
,
expr
);
int
fl
_impl_tags
=
(
arg
->
mod
->
module_flags
&
MSF_IMPLICIT_TAGS
);
int
module
_impl_tags
=
(
arg
->
mod
->
module_flags
&
MSF_IMPLICIT_TAGS
);
int
r_value
=
0
;
int
r_value
=
0
;
if
(
fl_impl_tags
)
{
if
(
expr
->
tag
.
tag_mode
==
TM_DEFAULT
)
{
if
(
expr
->
tag
.
tag_mode
!=
TM_EXPLICIT
)
{
if
(
must_explicit
||
module_impl_tags
==
0
)
if
(
must_explicit
)
expr
->
tag
.
tag_mode
=
TM_EXPLICIT
;
expr
->
tag
.
tag_mode
=
TM_EXPLICIT
;
else
else
expr
->
tag
.
tag_mode
=
TM_IMPLICIT
;
expr
->
tag
.
tag_mode
=
TM_IMPLICIT
;
}
}
}
else
{
if
(
expr
->
tag
.
tag_mode
==
TM_DEFAULT
)
{
expr
->
tag
.
tag_mode
=
TM_EXPLICIT
;
}
}
/*
/*
* Perform a final sanity check.
* Perform a final sanity check.
...
...
skeletons/OCTET_STRING.c
View file @
07f388cf
...
@@ -85,6 +85,15 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = {
...
@@ -85,6 +85,15 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = {
st->buf[st->size] = '\0'; \
st->buf[st->size] = '\0'; \
} while(0)
} while(0)
/*
* Internal variant of the OCTET STRING.
*/
typedef
enum
OS_type
{
_TT_GENERIC
=
0
,
/* Just a random OCTET STRING */
_TT_BIT_STRING
=
1
,
/* BIT STRING type, a special case */
_TT_ANY
=
2
,
/* ANY type, a special case too */
}
OS_type_e
;
/*
/*
* The main reason why ASN.1 is still alive is that too much time and effort
* The main reason why ASN.1 is still alive is that too much time and effort
* is necessary for learning it more or less adequately, thus creating a gut
* is necessary for learning it more or less adequately, thus creating a gut
...
@@ -161,11 +170,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
...
@@ -161,11 +170,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
struct
_stack
*
stck
;
/* A stack structure */
struct
_stack
*
stck
;
/* A stack structure */
struct
_stack_el
*
sel
=
0
;
/* Stack element */
struct
_stack_el
*
sel
=
0
;
/* Stack element */
int
tlv_constr
;
int
tlv_constr
;
enum
type_type_e
{
OS_type_e
type_type
=
(
OS_type_e
)(
int
)
td
->
specifics
;
_TT_GENERIC
=
0
,
/* Just a random OCTET STRING */
_TT_BIT_STRING
=
1
,
/* BIT STRING type, a special case */
_TT_ANY
=
2
,
/* ANY type, a special case too */
}
type_type
=
(
enum
type_type_e
)(
int
)
td
->
specifics
;
ASN_DEBUG
(
"Decoding %s as %s (frame %ld)"
,
ASN_DEBUG
(
"Decoding %s as %s (frame %ld)"
,
td
->
name
,
td
->
name
,
...
@@ -214,7 +219,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
...
@@ -214,7 +219,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
* Jump into stackless primitive decoding.
* Jump into stackless primitive decoding.
*/
*/
_CH_PHASE
(
ctx
,
3
);
_CH_PHASE
(
ctx
,
3
);
if
(
type_type
==
_TT_ANY
)
if
(
type_type
==
_TT_ANY
&&
tag_mode
!=
1
)
APPEND
(
buf_ptr
,
rval
.
consumed
);
APPEND
(
buf_ptr
,
rval
.
consumed
);
ADVANCE
(
rval
.
consumed
);
ADVANCE
(
rval
.
consumed
);
goto
phase3
;
goto
phase3
;
...
@@ -291,7 +296,9 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
...
@@ -291,7 +296,9 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
ASN_DEBUG
(
"Eat EOC; wn=%d--"
,
sel
->
want_nulls
);
ASN_DEBUG
(
"Eat EOC; wn=%d--"
,
sel
->
want_nulls
);
if
(
type_type
==
_TT_ANY
)
APPEND
(
"
\0\0
"
,
2
);
if
(
type_type
==
_TT_ANY
&&
(
tag_mode
!=
1
||
sel
->
cont_level
))
APPEND
(
"
\0\0
"
,
2
);
ADVANCE
(
2
);
ADVANCE
(
2
);
sel
->
got
+=
2
;
sel
->
got
+=
2
;
...
@@ -377,7 +384,9 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
...
@@ -377,7 +384,9 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
}
else
{
}
else
{
sel
->
left
=
tlv_len
;
sel
->
left
=
tlv_len
;
}
}
if
(
type_type
==
_TT_ANY
)
APPEND
(
buf_ptr
,
tlvl
);
if
(
type_type
==
_TT_ANY
&&
(
tag_mode
!=
1
||
sel
->
cont_level
))
APPEND
(
buf_ptr
,
tlvl
);
sel
->
got
+=
tlvl
;
sel
->
got
+=
tlvl
;
ADVANCE
(
tlvl
);
ADVANCE
(
tlvl
);
...
@@ -492,8 +501,7 @@ OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -492,8 +501,7 @@ OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
asn_enc_rval_t
erval
;
asn_enc_rval_t
erval
;
OCTET_STRING_t
*
st
=
(
OCTET_STRING_t
*
)
ptr
;
OCTET_STRING_t
*
st
=
(
OCTET_STRING_t
*
)
ptr
;
int
add_byte
=
0
;
int
add_byte
=
0
;
int
is_bit_str
=
(
td
->
specifics
==
(
void
*
)
1
);
OS_type_e
type_type
=
(
OS_type_e
)(
int
)
td
->
specifics
;
int
is_ANY_type
=
(
td
->
specifics
==
(
void
*
)
2
);
ASN_DEBUG
(
"%s %s as OCTET STRING"
,
ASN_DEBUG
(
"%s %s as OCTET STRING"
,
cb
?
"Estimating"
:
"Encoding"
,
td
->
name
);
cb
?
"Estimating"
:
"Encoding"
,
td
->
name
);
...
@@ -501,7 +509,7 @@ OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -501,7 +509,7 @@ OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
/*
/*
* Canonicalize BIT STRING.
* Canonicalize BIT STRING.
*/
*/
if
(
is_bit_str
&&
st
->
buf
)
{
if
(
type_type
==
_TT_BIT_STRING
)
{
switch
(
st
->
size
)
{
switch
(
st
->
size
)
{
case
0
:
add_byte
=
1
;
break
;
case
0
:
add_byte
=
1
;
break
;
case
1
:
st
->
buf
[
0
]
=
0
;
break
;
case
1
:
st
->
buf
[
0
]
=
0
;
break
;
...
@@ -511,16 +519,21 @@ OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -511,16 +519,21 @@ OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
}
}
}
}
if
(
is_ANY_type
)
{
/*
erval
.
encoded
=
0
;
* Write tags.
}
else
{
*/
if
(
type_type
!=
_TT_ANY
||
tag_mode
==
1
)
{
erval
.
encoded
=
der_write_tags
(
td
,
st
->
size
+
add_byte
,
erval
.
encoded
=
der_write_tags
(
td
,
st
->
size
+
add_byte
,
tag_mode
,
0
,
tag
,
cb
,
app_key
);
tag_mode
,
type_type
==
_TT_ANY
,
tag
,
cb
,
app_key
);
if
(
erval
.
encoded
==
-
1
)
{
if
(
erval
.
encoded
==
-
1
)
{
erval
.
failed_type
=
td
;
erval
.
failed_type
=
td
;
erval
.
structure_ptr
=
ptr
;
erval
.
structure_ptr
=
ptr
;
return
erval
;
return
erval
;
}
}
}
else
{
/* Disallow: [...] IMPLICIT ANY */
assert
(
type_type
!=
_TT_ANY
||
tag_mode
!=
-
1
);
erval
.
encoded
=
0
;
}
}
if
(
cb
)
{
if
(
cb
)
{
...
...
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