Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Havar
asn1c
Commits
35631487
Commit
35631487
authored
Jul 01, 2004
by
Lev Walkin
Browse files
extensibility check
parent
7ccf2a44
Changes
6
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
35631487
0.8.14: 2004-Jun-30
* Fixed compiler: extensibility of CHOICE and SET type has not been
taken into account during table construction.
(Test case 47) (Severity: high, Security impact: low)
0.8.13: 2004-Jun-29
* Fixed compiler: the skip values for IMPLICIT tagging were broken
...
...
configure
View file @
35631487
...
...
@@ -1881,7 +1881,7 @@ fi
# Define the identity of the package.
PACKAGE=asn1c
VERSION=0.8.1
3
VERSION=0.8.1
4
cat >>confdefs.h <<_ACEOF
...
...
configure.in
View file @
35631487
...
...
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(libasn1parser/asn1p_y.y)
AC_CANONICAL_SYSTEM
AC_PREREQ(2.53)
AM_INIT_AUTOMAKE(asn1c, 0.8.1
3
)
AM_INIT_AUTOMAKE(asn1c, 0.8.1
4
)
AC_SUBST(PATH)
...
...
libasn1compiler/asn1c_C.c
View file @
35631487
...
...
@@ -22,6 +22,7 @@ static int asn1c_lang_C_type_SET_def(arg_t *arg);
static
int
asn1c_lang_C_type_CHOICE_def
(
arg_t
*
arg
);
static
int
asn1c_lang_C_type_SEx_OF_def
(
arg_t
*
arg
,
int
seq_of
);
static
int
_print_tag
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
struct
asn1p_type_tag_s
*
tag_p
);
static
int
check_if_extensible
(
asn1p_expr_t
*
expr
);
static
int
emit_tags_vector
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
int
*
tags_impl_skip
);
static
int
emit_tag2member_map
(
arg_t
*
arg
,
tag2el_t
*
tag2el
,
int
tag2el_count
);
static
int
emit_constraint_checking_code
(
arg_t
*
arg
);
...
...
@@ -400,7 +401,6 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
int
elements
;
int
tags_impl_skip
=
0
;
int
comp_mode
=
0
;
/* {root,ext=1,root,root,...} */
int
extensible
=
0
;
tag2el_t
*
tag2el
=
NULL
;
int
tag2el_count
=
0
;
char
*
p
;
...
...
@@ -518,7 +518,8 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
OUT
(
"%d,
\t
/* Elements count */
\n
"
,
elements
);
OUT
(
"asn1_DEF_%s_tag2el,
\n
"
,
p
);
OUT
(
"%d,
\t
/* Count of tags in the map */
\n
"
,
tag2el_count
);
OUT
(
"%d,
\t
/* Whether extensible */
\n
"
,
extensible
);
OUT
(
"%d,
\t
/* Whether extensible */
\n
"
,
check_if_extensible
(
expr
));
OUT
(
"(unsigned int *)asn1_DEF_%s_mmap
\t
/* Mandatory elements map */
\n
"
,
p
);
);
OUT
(
"};
\n
"
);
...
...
@@ -720,7 +721,6 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
int
elements
;
/* Number of elements */
int
tags_impl_skip
=
0
;
int
comp_mode
=
0
;
/* {root,ext=1,root,root,...} */
int
extensible
=
0
;
tag2el_t
*
tag2el
=
NULL
;
int
tag2el_count
=
0
;
char
*
p
;
...
...
@@ -821,7 +821,8 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
OUT
(
"%d,
\t
/* Elements count */
\n
"
,
elements
);
OUT
(
"asn1_DEF_%s_tag2el,
\n
"
,
p
);
OUT
(
"%d,
\t
/* Count of tags in the map */
\n
"
,
tag2el_count
);
OUT
(
"%d
\t
/* Whether extensible */
\n
"
,
extensible
);
OUT
(
"%d
\t
/* Whether extensible */
\n
"
,
check_if_extensible
(
expr
));
);
OUT
(
"};
\n
"
);
OUT
(
"asn1_TYPE_descriptor_t asn1_DEF_%s = {
\n
"
,
p
);
...
...
@@ -1082,6 +1083,14 @@ asn1c_lang_C_type_EXTENSIBLE(arg_t *arg) {
return
0
;
}
static
int
check_if_extensible
(
asn1p_expr_t
*
expr
)
{
asn1p_expr_t
*
v
;
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
return
1
;
}
return
0
;
}
static
int
_print_tag
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
struct
asn1p_type_tag_s
*
tag_p
)
{
struct
asn1p_type_tag_s
tag
;
...
...
@@ -1996,3 +2005,4 @@ _find_terminal_type(arg_t *arg) {
if
(
expr
)
return
expr
->
expr_type
;
return
A1TC_INVALID
;
}
tests/47-set-ext-OK.asn1
0 → 100644
View file @
35631487
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .47
ModuleSetChoiceExtensibility
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 47 }
DEFINITIONS IMPLICIT TAGS EXTENSIBILITY IMPLIED ::=
BEGIN
T1 ::= SET { i INTEGER }
T2 ::= SET { i INTEGER, ... }
T3 ::= CHOICE { i INTEGER }
T4 ::= CHOICE { i INTEGER, ... }
END
tests/47-set-ext-OK.asn1.-P
0 → 100644
View file @
35631487
/*** <<< DEPS [T1] >>> ***/
/* Dependencies for T1 */
#include <INTEGER.h>
/*
* Method of determining the components presence
*/
enum T1_PR_e {
T1_PR_i, /* Member i is present */
};
#include <constr_SET.h>
extern asn1_TYPE_descriptor_t asn1_DEF_T1;
/*** <<< TYPE-DECLS [T1] >>> ***/
typedef struct T1 {
INTEGER_t i;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Presence bitmask: ASN_SET_ISPRESENT(pT1, T1_PR_x) */
unsigned int _presence_map
[((1+(8*sizeof(unsigned int))-1)/(8*sizeof(unsigned int)))];
/* Context for parsing across buffer boundaries */
ber_dec_ctx_t _ber_dec_ctx;
} T1_t;
/*** <<< STAT-DEFS [T1] >>> ***/
#include <constr_SET.h>
static asn1_SET_element_t asn1_DEF_T1_elements[] = {
{ offsetof(struct T1, i), 0,
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
(void *)&asn1_DEF_INTEGER,
"i"
},
};
static ber_tlv_tag_t asn1_DEF_T1_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static asn1_TYPE_tag2member_t asn1_DEF_T1_tag2el[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* i at 14 */
};
static uint8_t asn1_DEF_T1_mmap[(1 + (8 * sizeof(unsigned int)) - 1) / 8] = {
(1 << 7)
};
static asn1_SET_specifics_t asn1_DEF_T1_specs = {
sizeof(struct T1),
offsetof(struct T1, _ber_dec_ctx),
offsetof(struct T1, _presence_map),
asn1_DEF_T1_elements,
1, /* Elements count */
asn1_DEF_T1_tag2el,
1, /* Count of tags in the map */
1, /* Whether extensible */
(unsigned int *)asn1_DEF_T1_mmap /* Mandatory elements map */
};
asn1_TYPE_descriptor_t asn1_DEF_T1 = {
"T1",
SET_constraint,
SET_decode_ber,
SET_encode_der,
SET_print,
SET_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_T1_tags,
sizeof(asn1_DEF_T1_tags)
/sizeof(asn1_DEF_T1_tags[0]),
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
&asn1_DEF_T1_specs /* Additional specs */
};
/*** <<< DEPS [T2] >>> ***/
/* Dependencies for T2 */
#include <INTEGER.h>
/*
* Method of determining the components presence
*/
enum T2_PR_e {
T2_PR_i, /* Member i is present */
};
#include <constr_SET.h>
extern asn1_TYPE_descriptor_t asn1_DEF_T2;
/*** <<< TYPE-DECLS [T2] >>> ***/
typedef struct T2 {
INTEGER_t i;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Presence bitmask: ASN_SET_ISPRESENT(pT2, T2_PR_x) */
unsigned int _presence_map
[((1+(8*sizeof(unsigned int))-1)/(8*sizeof(unsigned int)))];
/* Context for parsing across buffer boundaries */
ber_dec_ctx_t _ber_dec_ctx;
} T2_t;
/*** <<< STAT-DEFS [T2] >>> ***/
#include <constr_SET.h>
static asn1_SET_element_t asn1_DEF_T2_elements[] = {
{ offsetof(struct T2, i), 0,
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
(void *)&asn1_DEF_INTEGER,
"i"
},
};
static ber_tlv_tag_t asn1_DEF_T2_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static asn1_TYPE_tag2member_t asn1_DEF_T2_tag2el[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* i at 15 */
};
static uint8_t asn1_DEF_T2_mmap[(1 + (8 * sizeof(unsigned int)) - 1) / 8] = {
(1 << 7)
};
static asn1_SET_specifics_t asn1_DEF_T2_specs = {
sizeof(struct T2),
offsetof(struct T2, _ber_dec_ctx),
offsetof(struct T2, _presence_map),
asn1_DEF_T2_elements,
1, /* Elements count */
asn1_DEF_T2_tag2el,
1, /* Count of tags in the map */
1, /* Whether extensible */
(unsigned int *)asn1_DEF_T2_mmap /* Mandatory elements map */
};
asn1_TYPE_descriptor_t asn1_DEF_T2 = {
"T2",
SET_constraint,
SET_decode_ber,
SET_encode_der,
SET_print,
SET_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_T2_tags,
sizeof(asn1_DEF_T2_tags)
/sizeof(asn1_DEF_T2_tags[0]),
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
&asn1_DEF_T2_specs /* Additional specs */
};
/*** <<< DEPS [T3] >>> ***/
/* Dependencies for T3 */
#include <INTEGER.h>
extern asn1_TYPE_descriptor_t asn1_DEF_T3;
/*** <<< TYPE-DECLS [T3] >>> ***/
typedef struct T3 {
enum {
T3_PR_NOTHING, /* No components present */
T3_PR_i,
} present;
union {
INTEGER_t i;
/*
* This type is extensible,
* possible extensions are below.
*/
} choice;
/* Context for parsing across buffer boundaries */
ber_dec_ctx_t _ber_dec_ctx;
} T3_t;
/*** <<< STAT-DEFS [T3] >>> ***/
#include <constr_CHOICE.h>
static asn1_CHOICE_element_t asn1_DEF_T3_elements[] = {
{ offsetof(struct T3, choice.i), 0,
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
(void *)&asn1_DEF_INTEGER,
"i"
},
};
static ber_tlv_tag_t asn1_DEF_T3_tags[] = {
};
static asn1_TYPE_tag2member_t asn1_DEF_T3_tag2el[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* i at 16 */
};
static asn1_CHOICE_specifics_t asn1_DEF_T3_specs = {
sizeof(struct T3),
offsetof(struct T3, _ber_dec_ctx),
offsetof(struct T3, present),
sizeof(((struct T3 *)0)->present),
asn1_DEF_T3_elements,
1, /* Elements count */
asn1_DEF_T3_tag2el,
1, /* Count of tags in the map */
1 /* Whether extensible */
};
asn1_TYPE_descriptor_t asn1_DEF_T3 = {
"T3",
CHOICE_constraint,
CHOICE_decode_ber,
CHOICE_encode_der,
CHOICE_print,
CHOICE_free,
CHOICE_outmost_tag,
asn1_DEF_T3_tags,
sizeof(asn1_DEF_T3_tags)
/sizeof(asn1_DEF_T3_tags[0]),
0, /* Tags to skip */
1, /* Whether CONSTRUCTED */
&asn1_DEF_T3_specs /* Additional specs */
};
/*** <<< DEPS [T4] >>> ***/
/* Dependencies for T4 */
#include <INTEGER.h>
extern asn1_TYPE_descriptor_t asn1_DEF_T4;
/*** <<< TYPE-DECLS [T4] >>> ***/
typedef struct T4 {
enum {
T4_PR_NOTHING, /* No components present */
T4_PR_i,
} present;
union {
INTEGER_t i;
/*
* This type is extensible,
* possible extensions are below.
*/
} choice;
/* Context for parsing across buffer boundaries */
ber_dec_ctx_t _ber_dec_ctx;
} T4_t;
/*** <<< STAT-DEFS [T4] >>> ***/
#include <constr_CHOICE.h>
static asn1_CHOICE_element_t asn1_DEF_T4_elements[] = {
{ offsetof(struct T4, choice.i), 0,
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
(void *)&asn1_DEF_INTEGER,
"i"
},
};
static ber_tlv_tag_t asn1_DEF_T4_tags[] = {
};
static asn1_TYPE_tag2member_t asn1_DEF_T4_tag2el[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* i at 17 */
};
static asn1_CHOICE_specifics_t asn1_DEF_T4_specs = {
sizeof(struct T4),
offsetof(struct T4, _ber_dec_ctx),
offsetof(struct T4, present),
sizeof(((struct T4 *)0)->present),
asn1_DEF_T4_elements,
1, /* Elements count */
asn1_DEF_T4_tag2el,
1, /* Count of tags in the map */
1 /* Whether extensible */
};
asn1_TYPE_descriptor_t asn1_DEF_T4 = {
"T4",
CHOICE_constraint,
CHOICE_decode_ber,
CHOICE_encode_der,
CHOICE_print,
CHOICE_free,
CHOICE_outmost_tag,
asn1_DEF_T4_tags,
sizeof(asn1_DEF_T4_tags)
/sizeof(asn1_DEF_T4_tags[0]),
0, /* Tags to skip */
1, /* Whether CONSTRUCTED */
&asn1_DEF_T4_specs /* Additional specs */
};
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