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
e0f2a5b4
Commit
e0f2a5b4
authored
Aug 30, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0..MAX is unsigned in constraints
parent
6713bcb0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
16 deletions
+34
-16
libasn1compiler/asn1c_constraint.c
libasn1compiler/asn1c_constraint.c
+12
-7
libasn1compiler/asn1c_misc.c
libasn1compiler/asn1c_misc.c
+3
-0
tests/tests-asn1c-compiler/50-constraint-OK.asn1.-Pgen-PER
tests/tests-asn1c-compiler/50-constraint-OK.asn1.-Pgen-PER
+1
-1
tests/tests-asn1c-compiler/90-cond-int-type-OK.asn1.-P
tests/tests-asn1c-compiler/90-cond-int-type-OK.asn1.-P
+9
-4
tests/tests-asn1c-compiler/90-cond-int-type-OK.asn1.-Pgen-PER
...s/tests-asn1c-compiler/90-cond-int-type-OK.asn1.-Pgen-PER
+9
-4
No files found.
libasn1compiler/asn1c_constraint.c
View file @
e0f2a5b4
...
@@ -12,16 +12,16 @@ static int emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, as
...
@@ -12,16 +12,16 @@ static int emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, as
static
int
emit_size_determination_code
(
arg_t
*
arg
,
asn1p_expr_type_e
etype
);
static
int
emit_size_determination_code
(
arg_t
*
arg
,
asn1p_expr_type_e
etype
);
static
asn1p_expr_type_e
_find_terminal_type
(
arg_t
*
arg
);
static
asn1p_expr_type_e
_find_terminal_type
(
arg_t
*
arg
);
static
int
emit_range_comparison_code
(
arg_t
*
arg
,
asn1cnst_range_t
*
range
,
const
char
*
varname
,
asn1c_integer_t
natural_start
,
asn1c_integer_t
natural_stop
);
static
int
emit_range_comparison_code
(
arg_t
*
arg
,
asn1cnst_range_t
*
range
,
const
char
*
varname
,
asn1c_integer_t
natural_start
,
asn1c_integer_t
natural_stop
);
static
int
native_long_sign
(
asn1cnst_range_t
*
r
);
/* -1, 0, 1 */
static
int
native_long_sign
(
a
rg_t
*
arg
,
a
sn1cnst_range_t
*
r
);
/* -1, 0, 1 */
static
int
static
int
ulong_optimization
(
asn1p_expr_type_e
etype
,
asn1cnst_range_t
*
r_size
,
ulong_optimization
(
a
rg_t
*
arg
,
a
sn1p_expr_type_e
etype
,
asn1cnst_range_t
*
r_size
,
asn1cnst_range_t
*
r_value
)
asn1cnst_range_t
*
r_value
)
{
{
return
(
!
r_size
&&
r_value
return
(
!
r_size
&&
r_value
&&
(
etype
==
ASN_BASIC_INTEGER
&&
(
etype
==
ASN_BASIC_INTEGER
||
etype
==
ASN_BASIC_ENUMERATED
)
||
etype
==
ASN_BASIC_ENUMERATED
)
&&
native_long_sign
(
r_value
)
==
0
);
&&
native_long_sign
(
arg
,
r_value
)
==
0
);
}
}
int
int
...
@@ -104,8 +104,8 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
...
@@ -104,8 +104,8 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
switch
(
etype
)
{
switch
(
etype
)
{
case
ASN_BASIC_INTEGER
:
case
ASN_BASIC_INTEGER
:
case
ASN_BASIC_ENUMERATED
:
case
ASN_BASIC_ENUMERATED
:
if
(
native_long_sign
(
r_value
)
>=
0
)
{
if
(
native_long_sign
(
arg
,
r_value
)
>=
0
)
{
ulong_optimize
=
ulong_optimization
(
etype
,
r_size
,
r_value
);
ulong_optimize
=
ulong_optimization
(
arg
,
etype
,
r_size
,
r_value
);
if
(
!
ulong_optimize
)
{
if
(
!
ulong_optimize
)
{
OUT
(
"unsigned long value;
\n
"
);
OUT
(
"unsigned long value;
\n
"
);
}
}
...
@@ -643,7 +643,7 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_rang
...
@@ -643,7 +643,7 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_rang
break
;
break
;
}
}
if
(
native_long_sign
(
r_value
)
>=
0
)
{
if
(
native_long_sign
(
arg
,
r_value
)
>=
0
)
{
/* Special case for treating unsigned longs */
/* Special case for treating unsigned longs */
OUT
(
"if(asn_INTEGER2ulong(st, &value)) {
\n
"
);
OUT
(
"if(asn_INTEGER2ulong(st, &value)) {
\n
"
);
INDENT
(
+
1
);
INDENT
(
+
1
);
...
@@ -710,7 +710,12 @@ _find_terminal_type(arg_t *arg) {
...
@@ -710,7 +710,12 @@ _find_terminal_type(arg_t *arg) {
}
}
static
int
static
int
native_long_sign
(
asn1cnst_range_t
*
r
)
{
native_long_sign
(
arg_t
*
arg
,
asn1cnst_range_t
*
r
)
{
if
(
!
(
arg
->
flags
&
A1C_USE_WIDE_TYPES
)
&&
r
->
left
.
type
==
ARE_VALUE
&&
r
->
left
.
value
>=
0
&&
r
->
left
.
value
<=
2147483647
&&
r
->
right
.
type
==
ARE_MAX
)
{
return
1
;
}
if
(
r
->
left
.
type
==
ARE_VALUE
if
(
r
->
left
.
type
==
ARE_VALUE
&&
r
->
left
.
value
>=
0
&&
r
->
left
.
value
>=
0
&&
r
->
right
.
type
==
ARE_VALUE
&&
r
->
right
.
type
==
ARE_VALUE
...
...
libasn1compiler/asn1c_misc.c
View file @
e0f2a5b4
...
@@ -406,6 +406,9 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
...
@@ -406,6 +406,9 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
asn1constraint_range_free
(
range
);
asn1constraint_range_free
(
range
);
/* Special case for unsigned */
/* Special case for unsigned */
if
(
!
(
arg
->
flags
&
A1C_USE_WIDE_TYPES
)
&&
left
.
type
==
ARE_VALUE
&&
left
.
value
>=
0
&&
left
.
value
<=
2147483647
&&
right
.
type
==
ARE_MAX
)
return
FL_FITS_UNSIGN
;
if
(
left
.
type
==
ARE_VALUE
if
(
left
.
type
==
ARE_VALUE
&&
left
.
value
>=
0
&&
left
.
value
>=
0
&&
right
.
type
==
ARE_VALUE
&&
right
.
type
==
ARE_VALUE
...
...
tests/tests-asn1c-compiler/50-constraint-OK.asn1.-Pgen-PER
View file @
e0f2a5b4
...
@@ -77,7 +77,7 @@ per_type_encoder_f Int2_encode_uper;
...
@@ -77,7 +77,7 @@ per_type_encoder_f Int2_encode_uper;
int
int
Int2_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
Int2_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
unsigned
long value;
if(!sptr) {
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
ASN__CTFAIL(app_key, td, sptr,
...
...
tests/tests-asn1c-compiler/90-cond-int-type-OK.asn1.-P
View file @
e0f2a5b4
...
@@ -356,7 +356,7 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerLowHigh = {
...
@@ -356,7 +356,7 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerLowHigh = {
/*** <<< TYPE-DECLS [CN-IntegerLowMax] >>> ***/
/*** <<< TYPE-DECLS [CN-IntegerLowMax] >>> ***/
typedef long CN_IntegerLowMax_t;
typedef
unsigned
long CN_IntegerLowMax_t;
/*** <<< FUNC-DECLS [CN-IntegerLowMax] >>> ***/
/*** <<< FUNC-DECLS [CN-IntegerLowMax] >>> ***/
...
@@ -374,7 +374,7 @@ xer_type_encoder_f CN_IntegerLowMax_encode_xer;
...
@@ -374,7 +374,7 @@ xer_type_encoder_f CN_IntegerLowMax_encode_xer;
int
int
CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
unsigned
long value;
if(!sptr) {
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
ASN__CTFAIL(app_key, td, sptr,
...
@@ -383,7 +383,7 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -383,7 +383,7 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
return -1;
return -1;
}
}
value = *(const long *)sptr;
value = *(const
unsigned
long *)sptr;
if((value >= 1)) {
if((value >= 1)) {
/* Constraint check succeeded */
/* Constraint check succeeded */
...
@@ -403,6 +403,11 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -403,6 +403,11 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
/*** <<< STAT-DEFS [CN-IntegerLowMax] >>> ***/
/*** <<< STAT-DEFS [CN-IntegerLowMax] >>> ***/
static const asn_INTEGER_specifics_t asn_SPC_CN_IntegerLowMax_specs_1 = {
0, 0, 0, 0, 0,
0, /* Native long size */
1 /* Unsigned representation */
};
static const ber_tlv_tag_t asn_DEF_CN_IntegerLowMax_tags_1[] = {
static const ber_tlv_tag_t asn_DEF_CN_IntegerLowMax_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
};
...
@@ -420,7 +425,7 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerLowMax = {
...
@@ -420,7 +425,7 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerLowMax = {
0, /* No OER visible constraints */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
0, /* No PER visible constraints */
0, 0, /* No members */
0, 0, /* No members */
0 /* No specifi
cs */
&asn_SPC_CN_IntegerLowMax_specs_1 /* Additional spe
cs */
};
};
...
...
tests/tests-asn1c-compiler/90-cond-int-type-OK.asn1.-Pgen-PER
View file @
e0f2a5b4
...
@@ -398,7 +398,7 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerLowHigh = {
...
@@ -398,7 +398,7 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerLowHigh = {
/*** <<< TYPE-DECLS [CN-IntegerLowMax] >>> ***/
/*** <<< TYPE-DECLS [CN-IntegerLowMax] >>> ***/
typedef long CN_IntegerLowMax_t;
typedef
unsigned
long CN_IntegerLowMax_t;
/*** <<< FUNC-DECLS [CN-IntegerLowMax] >>> ***/
/*** <<< FUNC-DECLS [CN-IntegerLowMax] >>> ***/
...
@@ -418,7 +418,7 @@ per_type_encoder_f CN_IntegerLowMax_encode_uper;
...
@@ -418,7 +418,7 @@ per_type_encoder_f CN_IntegerLowMax_encode_uper;
int
int
CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
unsigned
long value;
if(!sptr) {
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
ASN__CTFAIL(app_key, td, sptr,
...
@@ -427,7 +427,7 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -427,7 +427,7 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
return -1;
return -1;
}
}
value = *(const long *)sptr;
value = *(const
unsigned
long *)sptr;
if((value >= 1)) {
if((value >= 1)) {
/* Constraint check succeeded */
/* Constraint check succeeded */
...
@@ -455,6 +455,11 @@ static asn_per_constraints_t asn_PER_type_CN_IntegerLowMax_constr_1 GCC_NOTUSED
...
@@ -455,6 +455,11 @@ static asn_per_constraints_t asn_PER_type_CN_IntegerLowMax_constr_1 GCC_NOTUSED
/*** <<< STAT-DEFS [CN-IntegerLowMax] >>> ***/
/*** <<< STAT-DEFS [CN-IntegerLowMax] >>> ***/
static const asn_INTEGER_specifics_t asn_SPC_CN_IntegerLowMax_specs_1 = {
0, 0, 0, 0, 0,
0, /* Native long size */
1 /* Unsigned representation */
};
static const ber_tlv_tag_t asn_DEF_CN_IntegerLowMax_tags_1[] = {
static const ber_tlv_tag_t asn_DEF_CN_IntegerLowMax_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
};
...
@@ -472,7 +477,7 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerLowMax = {
...
@@ -472,7 +477,7 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerLowMax = {
0, /* No OER visible constraints */
0, /* No OER visible constraints */
&asn_PER_type_CN_IntegerLowMax_constr_1,
&asn_PER_type_CN_IntegerLowMax_constr_1,
0, 0, /* No members */
0, 0, /* No members */
0 /* No specifi
cs */
&asn_SPC_CN_IntegerLowMax_specs_1 /* Additional spe
cs */
};
};
...
...
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