Commit 6bc5696f authored by Lev Walkin's avatar Lev Walkin

fix consrtaint propagation for random_fill

parent d14802fa
...@@ -571,7 +571,8 @@ BIT_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, ...@@ -571,7 +571,8 @@ BIT_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
/* Figure out how far we should go */ /* Figure out how far we should go */
rnd_bits = lengths[asn_random_between( rnd_bits = lengths[asn_random_between(
0, sizeof(lengths) / sizeof(lengths[0]) - 1)]; 0, sizeof(lengths) / sizeof(lengths[0]) - 1)];
if(!constraints) constraints = &td->encoding_constraints; if(!constraints || !constraints->per_constraints)
constraints = &td->encoding_constraints;
if(constraints->per_constraints) { if(constraints->per_constraints) {
const asn_per_constraint_t *pc = &constraints->per_constraints->size; const asn_per_constraint_t *pc = &constraints->per_constraints->size;
if(pc->flags & APC_CONSTRAINED) { if(pc->flags & APC_CONSTRAINED) {
......
...@@ -406,7 +406,8 @@ BOOLEAN_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, ...@@ -406,7 +406,8 @@ BOOLEAN_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
} }
} }
if(!constraints) constraints = &td->encoding_constraints; if(!constraints || !constraints->per_constraints)
constraints = &td->encoding_constraints;
if(constraints->per_constraints) { if(constraints->per_constraints) {
const asn_per_constraint_t *pc = &constraints->per_constraints->value; const asn_per_constraint_t *pc = &constraints->per_constraints->value;
if(pc->flags & APC_CONSTRAINED) { if(pc->flags & APC_CONSTRAINED) {
......
...@@ -1886,10 +1886,10 @@ OCTET_STRING_random_length_constrained( ...@@ -1886,10 +1886,10 @@ OCTET_STRING_random_length_constrained(
rnd_len = lengths[asn_random_between( rnd_len = lengths[asn_random_between(
0, sizeof(lengths) / sizeof(lengths[0]) - 1)]; 0, sizeof(lengths) / sizeof(lengths[0]) - 1)];
if(!constraints) constraints = &td->encoding_constraints; if(!constraints || !constraints->per_constraints)
constraints = &td->encoding_constraints;
if(constraints->per_constraints) { if(constraints->per_constraints) {
const asn_per_constraint_t *pc = const asn_per_constraint_t *pc = &constraints->per_constraints->size;
&td->encoding_constraints.per_constraints->size;
if(pc->flags & APC_CONSTRAINED) { if(pc->flags & APC_CONSTRAINED) {
long suggested_upper_bound = pc->upper_bound < (ssize_t)max_length long suggested_upper_bound = pc->upper_bound < (ssize_t)max_length
? pc->upper_bound ? pc->upper_bound
...@@ -1977,10 +1977,10 @@ OCTET_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, ...@@ -1977,10 +1977,10 @@ OCTET_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
break; break;
} }
if(!constraints) constraints = &td->encoding_constraints; if(!constraints || !constraints->per_constraints)
constraints = &td->encoding_constraints;
if(constraints->per_constraints) { if(constraints->per_constraints) {
const asn_per_constraint_t *pc = const asn_per_constraint_t *pc = &constraints->per_constraints->value;
&td->encoding_constraints.per_constraints->value;
if(pc->flags & APC_SEMI_CONSTRAINED) { if(pc->flags & APC_SEMI_CONSTRAINED) {
clb = pc->lower_bound; clb = pc->lower_bound;
} else if(pc->flags & APC_CONSTRAINED) { } else if(pc->flags & APC_CONSTRAINED) {
......
...@@ -7,6 +7,12 @@ SEQUENCE { ..., null NULL OPTIONAL } ...@@ -7,6 +7,12 @@ SEQUENCE { ..., null NULL OPTIONAL }
SEQUENCE { ..., null BOOLEAN } SEQUENCE { ..., null BOOLEAN }
SEQUENCE { ..., null BOOLEAN DEFAULT FALSE } SEQUENCE { ..., null BOOLEAN DEFAULT FALSE }
SEQUENCE { ..., null BOOLEAN DEFAULT TRUE } SEQUENCE { ..., null BOOLEAN DEFAULT TRUE }
SEQUENCE { str IA5String }
SEQUENCE { str IA5String OPTIONAL }
SEQUENCE { str IA5String (SIZE(0)) }
SEQUENCE { str IA5String (SIZE(0)) OPTIONAL }
SEQUENCE { str IA5String (SIZE(1)) }
SEQUENCE { str IA5String (SIZE(1)) OPTIONAL }
SEQUENCE { null NULL } SEQUENCE { null NULL }
SEQUENCE { null NULL, ... } SEQUENCE { null NULL, ... }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment