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
1ef0516f
Commit
1ef0516f
authored
Aug 25, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed constraint code
parent
c8474640
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
26 deletions
+55
-26
libasn1fix/asn1fix.c
libasn1fix/asn1fix.c
+45
-22
libasn1fix/asn1fix_constr.c
libasn1fix/asn1fix_constr.c
+3
-3
libasn1fix/asn1fix_crange.c
libasn1fix/asn1fix_crange.c
+7
-1
No files found.
libasn1fix/asn1fix.c
View file @
1ef0516f
...
...
@@ -15,7 +15,8 @@ static void _default_error_logger(int _severity, const char *fmt, ...);
static
int
asn1f_fix_module
(
arg_t
*
arg
);
static
int
asn1f_fix_simple
(
arg_t
*
arg
);
/* For INTEGER/ENUMERATED */
static
int
asn1f_fix_constructed
(
arg_t
*
arg
);
/* For SEQUENCE/SET/CHOICE */
static
int
asn1f_fix_constraints
(
arg_t
*
arg
);
/* For subtype constraints */
static
int
asn1f_resolve_constraints
(
arg_t
*
arg
);
/* For subtype constraints */
static
int
asn1f_check_constraints
(
arg_t
*
arg
);
/* For subtype constraints */
arg_t
a1f_replace_me_with_proper_interface_arg
;
...
...
@@ -102,6 +103,7 @@ static int
asn1f_fix_module
(
arg_t
*
arg
)
{
asn1p_expr_t
*
expr
;
int
rvalue
=
0
;
int
ret
;
switch
((
arg
->
mod
->
module_flags
&
MSF_MASK_TAGS
))
{
case
MSF_NOFLAGS
:
...
...
@@ -140,7 +142,6 @@ asn1f_fix_module(arg_t *arg) {
* Order is not important.
*/
TQ_FOR
(
expr
,
&
(
arg
->
mod
->
members
),
next
)
{
int
ret
;
arg
->
expr
=
expr
;
if
(
expr
->
meta_type
==
AMT_PARAMTYPE
)
...
...
@@ -178,7 +179,7 @@ asn1f_fix_module(arg_t *arg) {
/*
* Resolve references in constraints.
*/
ret
=
asn1f_recurse_expr
(
arg
,
asn1f_
fix
_constraints
);
ret
=
asn1f_recurse_expr
(
arg
,
asn1f_
resolve
_constraints
);
RET2RVAL
(
ret
,
rvalue
);
/*
...
...
@@ -195,7 +196,6 @@ asn1f_fix_module(arg_t *arg) {
* 5. Automatic tagging
*/
TQ_FOR
(
expr
,
&
(
arg
->
mod
->
members
),
next
)
{
int
ret
;
arg
->
expr
=
expr
;
...
...
@@ -210,7 +210,6 @@ asn1f_fix_module(arg_t *arg) {
* 9. fix spaces in cstrings
*/
TQ_FOR
(
expr
,
&
(
arg
->
mod
->
members
),
next
)
{
int
ret
;
arg
->
expr
=
expr
;
ret
=
asn1f_recurse_expr
(
arg
,
asn1f_fix_bit_string
);
...
...
@@ -226,7 +225,6 @@ asn1f_fix_module(arg_t *arg) {
* ... Check for tags distinctness.
*/
TQ_FOR
(
expr
,
&
(
arg
->
mod
->
members
),
next
)
{
int
ret
;
arg
->
expr
=
expr
;
ret
=
asn1f_recurse_expr
(
arg
,
asn1f_check_constr_tags_distinct
);
...
...
@@ -235,6 +233,18 @@ asn1f_fix_module(arg_t *arg) {
assert
(
arg
->
expr
==
expr
);
}
/*
* Check semantic validity of constraints.
*/
TQ_FOR
(
expr
,
&
(
arg
->
mod
->
members
),
next
)
{
arg
->
expr
=
expr
;
ret
=
asn1f_recurse_expr
(
arg
,
asn1f_check_constraints
);
RET2RVAL
(
ret
,
rvalue
);
assert
(
arg
->
expr
==
expr
);
}
return
rvalue
;
}
...
...
@@ -287,7 +297,7 @@ asn1f_fix_constructed(arg_t *arg) {
}
static
int
asn1f_
fix
_constraints
(
arg_t
*
arg
)
{
asn1f_
resolve
_constraints
(
arg_t
*
arg
)
{
asn1p_expr_t
*
top_parent
;
asn1p_expr_type_e
etype
;
int
rvalue
=
0
;
...
...
@@ -302,25 +312,38 @@ asn1f_fix_constraints(arg_t *arg) {
arg
->
expr
->
constraints
,
etype
,
0
);
RET2RVAL
(
ret
,
rvalue
);
return
rvalue
;
}
static
int
asn1f_check_constraints
(
arg_t
*
arg
)
{
static
enum
asn1p_constraint_type_e
test_types
[]
=
{
ACT_EL_RANGE
,
ACT_CT_SIZE
,
ACT_CT_FROM
};
asn1p_expr_t
*
top_parent
;
asn1cnst_range_t
*
range
;
asn1p_expr_type_e
etype
;
unsigned
int
i
;
int
rvalue
=
0
;
int
ret
;
top_parent
=
asn1f_find_terminal_type
(
arg
,
arg
->
expr
);
if
(
!
top_parent
)
return
0
;
etype
=
top_parent
->
expr_type
;
ret
=
asn1constraint_pullup
(
arg
);
RET2RVAL
(
ret
,
rvalue
);
if
(
top_parent
)
{
static
enum
asn1p_constraint_type_e
test_types
[]
=
{
ACT_EL_RANGE
,
ACT_CT_SIZE
,
ACT_CT_FROM
};
unsigned
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
test_types
)
/
sizeof
(
test_types
[
0
]);
i
++
)
{
asn1cnst_range_t
*
range
;
range
=
asn1constraint_compute_PER_range
(
top_parent
->
expr_type
,
arg
->
expr
->
combined_constraints
,
test_types
[
i
],
0
,
0
);
if
(
!
range
&&
errno
==
EPERM
)
return
-
1
;
asn1constraint_range_free
(
range
);
}
for
(
i
=
0
;
i
<
sizeof
(
test_types
)
/
sizeof
(
test_types
[
0
]);
i
++
)
{
range
=
asn1constraint_compute_PER_range
(
top_parent
->
expr_type
,
arg
->
expr
->
combined_constraints
,
test_types
[
i
],
0
,
0
);
if
(
!
range
&&
errno
==
EPERM
)
return
-
1
;
asn1constraint_range_free
(
range
);
}
return
rvalue
;
}
...
...
libasn1fix/asn1fix_constr.c
View file @
1ef0516f
...
...
@@ -72,7 +72,7 @@ asn1f_pull_components_of(arg_t *arg) {
}
/* Move the stuff back */
TQ_
HEAD_COPY
(
&
(
expr
->
members
),
&
list
);
TQ_
MOVE
(
&
(
expr
->
members
),
&
list
);
return
r_value
;
}
...
...
@@ -133,12 +133,12 @@ asn1f_fix_constr_ext(arg_t *arg) {
/*
* Copy the root list and extension list back into the main list.
*/
TQ_
HEAD_COPY
(
&
(
expr
->
members
),
&
root_list
);
TQ_
MOVE
(
&
(
expr
->
members
),
&
root_list
);
while
((
v
=
TQ_REMOVE
(
&
ext_list
,
next
)))
TQ_ADD
(
&
(
expr
->
members
),
v
,
next
);
if
(
arg
->
mod
->
module_flags
&
MSF_EXTENSIBILITY_IMPLIED
&&
ext_count
<
1
)
{
&&
ext_count
==
0
)
{
v
=
asn1p_expr_new
(
0
);
if
(
v
)
{
v
->
Identifier
=
strdup
(
"..."
);
...
...
libasn1fix/asn1fix_crange.c
View file @
1ef0516f
...
...
@@ -313,6 +313,11 @@ static int _range_fill(asn1p_value_t *val, const asn1cnst_range_t *minmax, asn1c
if
(
type
!=
ACT_CT_FROM
)
return
0
;
break
;
case
ATV_REFERENCED
:
FATAL
(
"Unrecognized constraint element
\"
%s
\"
at line %d"
,
asn1f_printable_reference
(
val
->
value
.
reference
),
lineno
);
return
-
1
;
default:
FATAL
(
"Unrecognized constraint element at line %d"
,
lineno
);
...
...
@@ -878,7 +883,8 @@ asn1constraint_compute_PER_range(asn1p_expr_type_e expr_type, const asn1p_constr
ret
=
_range_fill
(
vmin
,
minmax
,
&
range
->
left
,
range
,
type
,
ct
->
_lineno
);
ret
|=
_range_fill
(
vmax
,
minmax
,
&
range
->
right
,
if
(
!
ret
)
ret
=
_range_fill
(
vmax
,
minmax
,
&
range
->
right
,
range
,
type
,
ct
->
_lineno
);
if
(
ret
)
{
_range_free
(
range
);
...
...
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