Merge PR99 and its fixes to support parsing Information Object and Information Object Set
This is a collection of works :
1. Based on @zhanglei002's pull request 99.
2. A fix by @AuthenticEshkinKot and merged by @mouse07410 at
commit 2c8d366bbe1fc4e4c041e9b0eb9779f8a42d754b of https://github.com/mouse07410/asn1c
to support parsing of Information Object and Information Object Set
3. A fix by @Uri Blumenthal in asn1fix_derefv.c at :
commit ec0ade4f87c807e763e3f35fc5466adb6dda3473 of https://github.com/mouse07410/asn1c
to solve crash on asn1p_value_free().
4. My pull request 18 to @mouse07410's https://github.com/mouse07410/asn1c to solve
problems found during parsing ASN.1 modules of S1AP, RANAP and J2735-201603.
5. My pull request 22 to @mouse07410's https://github.com/mouse07410/asn1c to solve issue 147
and to solve the problem during parsing ASN.1 module of NBAP.
6. My pull request 23 to @mouse07410's https://github.com/mouse07410/asn1c to fix memory leakage
introduced in aforementioned commits.
Most code changes are the same as pull request 153 to this repository.
7. A fix of my bug in item 6 which result asn1c crash, fixed by @mouse07410.
diff --git a/libasn1fix/asn1fix_constraint.c b/libasn1fix/asn1fix_constraint.c
index 847bdce..97fa589 100644
--- a/libasn1fix/asn1fix_constraint.c
+++ b/libasn1fix/asn1fix_constraint.c
@@ -4,6 +4,7 @@
static void _remove_extensions(arg_t *arg, asn1p_constraint_t *ct, int flast);
static int constraint_type_resolve(arg_t *arg, asn1p_constraint_t *ct);
+static int constraint_object_resolve(arg_t *arg, asn1p_value_t *value);
static int constraint_value_resolve(arg_t *arg, asn1p_value_t **value, enum asn1p_constraint_type_e real_ctype);
int
@@ -214,6 +215,10 @@
&ct->range_stop, real_constraint_type);
RET2RVAL(ret, rvalue);
}
+ if (ct->value && ct->value->type == ATV_UNPARSED && etype == A1TC_CLASSDEF) {
+ ret = constraint_object_resolve(arg, ct->value);
+ RET2RVAL(ret, rvalue);
+ }
/*
* Proceed recursively.
@@ -346,3 +351,24 @@
return rvalue;
}
+static int
+constraint_object_resolve(arg_t *arg, asn1p_value_t *value) {
+ asn1p_expr_t tmp_expr = *arg->expr;
+ asn1p_expr_t *saved_expr = arg->expr;
+
+ tmp_expr.meta_type = AMT_VALUE;
+ tmp_expr.expr_type = A1TC_REFERENCE;
+ tmp_expr.value = value;
+ arg->expr = &tmp_expr;
+
+ if (asn1f_check_class_object(arg)) {
+ arg->expr = saved_expr;
+ FATAL("Parsing ObjectSet %s failed at %d", arg->expr->Identifier,
+ arg->expr->_lineno);
+ return -1;
+ }
+
+ arg->expr = saved_expr;
+ return 0;
+}
+