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
f6e04b55
Commit
f6e04b55
authored
Sep 11, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ignore single value constraint which looks like a (bit)string itself
parent
59165cf2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
26 deletions
+73
-26
libasn1fix/asn1fix_crange.c
libasn1fix/asn1fix_crange.c
+42
-26
tests/tests-asn1c-compiler/153-single-value-constraint-OK.asn1
.../tests-asn1c-compiler/153-single-value-constraint-OK.asn1
+19
-0
tests/tests-asn1c-compiler/153-single-value-constraint-OK.asn1.-EF
...ts-asn1c-compiler/153-single-value-constraint-OK.asn1.-EF
+12
-0
No files found.
libasn1fix/asn1fix_crange.c
View file @
f6e04b55
...
@@ -250,7 +250,12 @@ static int _range_merge_in(asn1cnst_range_t *into, asn1cnst_range_t *cr) {
...
@@ -250,7 +250,12 @@ static int _range_merge_in(asn1cnst_range_t *into, asn1cnst_range_t *cr) {
return
0
;
return
0
;
}
}
static
int
_range_fill
(
asn1p_value_t
*
val
,
const
asn1cnst_range_t
*
minmax
,
asn1cnst_edge_t
*
edge
,
asn1cnst_range_t
*
range
,
enum
asn1p_constraint_type_e
type
,
int
lineno
)
{
enum
range_fill_result
{
RFR_OK
,
RFR_FAIL
,
RFR_INCOMPATIBLE
};
static
enum
range_fill_result
_range_fill
(
asn1p_value_t
*
val
,
const
asn1cnst_range_t
*
minmax
,
asn1cnst_edge_t
*
edge
,
asn1cnst_range_t
*
range
,
enum
asn1p_constraint_type_e
type
,
int
lineno
)
{
unsigned
char
*
p
,
*
pend
;
unsigned
char
*
p
,
*
pend
;
edge
->
lineno
=
lineno
;
edge
->
lineno
=
lineno
;
...
@@ -262,31 +267,31 @@ static int _range_fill(asn1p_value_t *val, const asn1cnst_range_t *minmax, asn1c
...
@@ -262,31 +267,31 @@ static int _range_fill(asn1p_value_t *val, const asn1cnst_range_t *minmax, asn1c
"for %s constraint at line %d"
,
"for %s constraint at line %d"
,
asn1p_itoa
(
val
->
value
.
v_integer
),
asn1p_itoa
(
val
->
value
.
v_integer
),
asn1p_constraint_type2str
(
type
),
lineno
);
asn1p_constraint_type2str
(
type
),
lineno
);
return
-
1
;
return
RFR_FAIL
;
}
}
edge
->
type
=
ARE_VALUE
;
edge
->
type
=
ARE_VALUE
;
edge
->
value
=
val
->
value
.
v_integer
;
edge
->
value
=
val
->
value
.
v_integer
;
return
0
;
return
RFR_OK
;
case
ATV_MIN
:
case
ATV_MIN
:
if
(
type
!=
ACT_EL_RANGE
&&
type
!=
ACT_CT_SIZE
)
{
if
(
type
!=
ACT_EL_RANGE
&&
type
!=
ACT_CT_SIZE
)
{
FATAL
(
"MIN invalid for %s constraint at line %d"
,
FATAL
(
"MIN invalid for %s constraint at line %d"
,
asn1p_constraint_type2str
(
type
),
lineno
);
asn1p_constraint_type2str
(
type
),
lineno
);
return
-
1
;
return
RFR_FAIL
;
}
}
edge
->
type
=
ARE_MIN
;
edge
->
type
=
ARE_MIN
;
if
(
minmax
)
*
edge
=
minmax
->
left
;
if
(
minmax
)
*
edge
=
minmax
->
left
;
edge
->
lineno
=
lineno
;
/* Restore lineno */
edge
->
lineno
=
lineno
;
/* Restore lineno */
return
0
;
return
RFR_OK
;
case
ATV_MAX
:
case
ATV_MAX
:
if
(
type
!=
ACT_EL_RANGE
&&
type
!=
ACT_CT_SIZE
)
{
if
(
type
!=
ACT_EL_RANGE
&&
type
!=
ACT_CT_SIZE
)
{
FATAL
(
"MAX invalid for %s constraint at line %d"
,
FATAL
(
"MAX invalid for %s constraint at line %d"
,
asn1p_constraint_type2str
(
type
),
lineno
);
asn1p_constraint_type2str
(
type
),
lineno
);
return
-
1
;
return
RFR_FAIL
;
}
}
edge
->
type
=
ARE_MAX
;
edge
->
type
=
ARE_MAX
;
if
(
minmax
)
*
edge
=
minmax
->
right
;
if
(
minmax
)
*
edge
=
minmax
->
right
;
edge
->
lineno
=
lineno
;
/* Restore lineno */
edge
->
lineno
=
lineno
;
/* Restore lineno */
return
0
;
return
RFR_OK
;
case
ATV_FALSE
:
case
ATV_FALSE
:
case
ATV_TRUE
:
case
ATV_TRUE
:
if
(
type
!=
ACT_EL_RANGE
)
{
if
(
type
!=
ACT_EL_RANGE
)
{
...
@@ -294,36 +299,40 @@ static int _range_fill(asn1p_value_t *val, const asn1cnst_range_t *minmax, asn1c
...
@@ -294,36 +299,40 @@ static int _range_fill(asn1p_value_t *val, const asn1cnst_range_t *minmax, asn1c
val
->
type
==
ATV_TRUE
?
"TRUE"
:
"FALSE"
,
val
->
type
==
ATV_TRUE
?
"TRUE"
:
"FALSE"
,
asn1p_constraint_type2str
(
type
),
asn1p_constraint_type2str
(
type
),
lineno
);
lineno
);
return
-
1
;
return
RFR_FAIL
;
}
}
edge
->
type
=
ARE_VALUE
;
edge
->
type
=
ARE_VALUE
;
edge
->
value
=
(
val
->
type
==
ATV_TRUE
);
edge
->
value
=
(
val
->
type
==
ATV_TRUE
);
return
0
;
return
RFR_OK
;
case
ATV_TUPLE
:
case
ATV_TUPLE
:
case
ATV_QUADRUPLE
:
case
ATV_QUADRUPLE
:
edge
->
type
=
ARE_VALUE
;
edge
->
type
=
ARE_VALUE
;
edge
->
value
=
val
->
value
.
v_integer
;
edge
->
value
=
val
->
value
.
v_integer
;
return
0
;
return
RFR_OK
;
case
ATV_STRING
:
case
ATV_STRING
:
if
(
type
!=
ACT_CT_FROM
)
if
(
type
!=
ACT_CT_FROM
)
return
0
;
return
RFR_OK
;
break
;
break
;
case
ATV_REFERENCED
:
case
ATV_REFERENCED
:
FATAL
(
"Unresolved constraint element
\"
%s
\"
at line %d"
,
FATAL
(
"Unresolved constraint element
\"
%s
\"
at line %d"
,
asn1f_printable_reference
(
val
->
value
.
reference
),
asn1f_printable_reference
(
val
->
value
.
reference
),
lineno
);
lineno
);
return
-
1
;
return
RFR_FAIL
;
case
ATV_BITVECTOR
:
/* Value constraint... not supported yet. */
/* OER: X.696 (08/2015) #8.2.2i */
return
RFR_INCOMPATIBLE
;
default:
default:
FATAL
(
"Unrecognized constraint
element
at line %d"
,
FATAL
(
"Unrecognized constraint
range element type %d
at line %d"
,
lineno
);
val
->
type
,
lineno
);
return
-
1
;
return
RFR_FAIL
;
}
}
assert
(
val
->
type
==
ATV_STRING
);
assert
(
val
->
type
==
ATV_STRING
);
p
=
val
->
value
.
string
.
buf
;
p
=
val
->
value
.
string
.
buf
;
pend
=
p
+
val
->
value
.
string
.
size
;
pend
=
p
+
val
->
value
.
string
.
size
;
if
(
p
==
pend
)
return
0
;
if
(
p
==
pend
)
return
RFR_OK
;
edge
->
type
=
ARE_VALUE
;
edge
->
type
=
ARE_VALUE
;
if
(
val
->
value
.
string
.
size
==
1
)
{
if
(
val
->
value
.
string
.
size
==
1
)
{
...
@@ -356,7 +365,7 @@ static int _range_fill(asn1p_value_t *val, const asn1cnst_range_t *minmax, asn1c
...
@@ -356,7 +365,7 @@ static int _range_fill(asn1p_value_t *val, const asn1cnst_range_t *minmax, asn1c
edge
->
value
=
(
edge
==
&
range
->
right
)
?
vmin
:
vmax
;
edge
->
value
=
(
edge
==
&
range
->
right
)
?
vmin
:
vmax
;
}
}
return
0
;
return
RFR_OK
;
}
}
/*
/*
...
@@ -1085,7 +1094,6 @@ asn1constraint_compute_constraint_range(
...
@@ -1085,7 +1094,6 @@ asn1constraint_compute_constraint_range(
return
range
;
return
range
;
}
}
if
(
!*
exmet
)
{
if
(
!*
exmet
)
{
/*
/*
* Expectation is not met. Return the default range.
* Expectation is not met. Return the default range.
...
@@ -1097,15 +1105,23 @@ asn1constraint_compute_constraint_range(
...
@@ -1097,15 +1105,23 @@ asn1constraint_compute_constraint_range(
_range_free
(
range
);
_range_free
(
range
);
range
=
_range_new
();
range
=
_range_new
();
ret
=
_range_fill
(
vmin
,
minmax
,
&
range
->
left
,
enum
range_fill_result
rfr
;
range
,
requested_ct_type
,
ct
->
_lineno
);
rfr
=
_range_fill
(
vmin
,
minmax
,
&
range
->
left
,
if
(
!
ret
)
ret
=
_range_fill
(
vmax
,
minmax
,
&
range
->
right
,
range
,
requested_ct_type
,
ct
->
_lineno
);
range
,
requested_ct_type
,
ct
->
_lineno
);
if
(
ret
)
{
if
(
rfr
==
RFR_OK
)
{
_range_free
(
range
);
rfr
=
_range_fill
(
vmax
,
minmax
,
&
range
->
right
,
errno
=
EPERM
;
range
,
requested_ct_type
,
ct
->
_lineno
);
return
NULL
;
}
switch
(
rfr
)
{
case
RFR_OK
:
break
;
case
RFR_FAIL
:
_range_free
(
range
);
errno
=
EPERM
;
return
NULL
;
case
RFR_INCOMPATIBLE
:
range
->
incompatible
=
1
;
return
range
;
}
}
if
(
minmax
)
{
if
(
minmax
)
{
...
...
tests/tests-asn1c-compiler/153-single-value-constraint-OK.asn1
0 → 100644
View file @
f6e04b55
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .153
ModuleSingleValueConstraint
{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 153 }
DEFINITIONS ::= BEGIN
zero8 OCTET STRING ::= '0000000000000000'H
Index ::= SEQUENCE {
padding OCTET STRING (SIZE(8)) (zero8)
}
END
tests/tests-asn1c-compiler/153-single-value-constraint-OK.asn1.-EF
0 → 100644
View file @
f6e04b55
ModuleSingleValueConstraint { iso org(3) dod(6) internet(1) private(4)
enterprise(1) spelio(9363) software(1) asn1c(5) test(1) 153 }
DEFINITIONS ::=
BEGIN
zero8 OCTET STRING ::= '0000000000000000'H
Index ::= SEQUENCE {
padding OCTET STRING (SIZE(8)) ('0000000000000000'H)
}
END
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