fix consrtaint propagation for random_fill

This commit is contained in:
Lev Walkin 2017-10-20 04:19:37 -07:00
parent d14802fa0f
commit 6bc5696f52
4 changed files with 16 additions and 8 deletions

View File

@ -571,7 +571,8 @@ BIT_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
/* Figure out how far we should go */
rnd_bits = lengths[asn_random_between(
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) {
const asn_per_constraint_t *pc = &constraints->per_constraints->size;
if(pc->flags & APC_CONSTRAINED) {

View File

@ -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) {
const asn_per_constraint_t *pc = &constraints->per_constraints->value;
if(pc->flags & APC_CONSTRAINED) {

View File

@ -1886,10 +1886,10 @@ OCTET_STRING_random_length_constrained(
rnd_len = lengths[asn_random_between(
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) {
const asn_per_constraint_t *pc =
&td->encoding_constraints.per_constraints->size;
const asn_per_constraint_t *pc = &constraints->per_constraints->size;
if(pc->flags & APC_CONSTRAINED) {
long suggested_upper_bound = pc->upper_bound < (ssize_t)max_length
? pc->upper_bound
@ -1977,10 +1977,10 @@ OCTET_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
break;
}
if(!constraints) constraints = &td->encoding_constraints;
if(!constraints || !constraints->per_constraints)
constraints = &td->encoding_constraints;
if(constraints->per_constraints) {
const asn_per_constraint_t *pc =
&td->encoding_constraints.per_constraints->value;
const asn_per_constraint_t *pc = &constraints->per_constraints->value;
if(pc->flags & APC_SEMI_CONSTRAINED) {
clb = pc->lower_bound;
} else if(pc->flags & APC_CONSTRAINED) {

View File

@ -7,6 +7,12 @@ SEQUENCE { ..., null NULL OPTIONAL }
SEQUENCE { ..., null BOOLEAN }
SEQUENCE { ..., null BOOLEAN DEFAULT FALSE }
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, ... }