diff options
author | Lev Walkin <vlm@lionet.info> | 2006-03-18 05:06:57 +0000 |
---|---|---|
committer | Lev Walkin <vlm@lionet.info> | 2006-03-18 05:06:57 +0000 |
commit | 41635d33ddf675afa61c742118a197e303930681 (patch) | |
tree | 408e6ec46f232629c672a2a53bb2ab8276535f44 /libasn1fix/asn1fix_retrieve.c | |
parent | d404427f6e9e07d85785de57a00d815e9af34b7b (diff) |
references
Diffstat (limited to 'libasn1fix/asn1fix_retrieve.c')
-rw-r--r-- | libasn1fix/asn1fix_retrieve.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/libasn1fix/asn1fix_retrieve.c b/libasn1fix/asn1fix_retrieve.c index 731c269e..2c004be5 100644 --- a/libasn1fix/asn1fix_retrieve.c +++ b/libasn1fix/asn1fix_retrieve.c @@ -58,7 +58,8 @@ asn1f_lookup_in_imports(arg_t *arg, asn1p_module_t *mod, const char *name) { arg->expr->_mark |= TM_BROKEN; FATAL("Cannot find external module \"%s\" " "mentioned for " - "\"%s\" at line %d", + "\"%s\" at line %d. " + "Obtain this module and instruct compiler to process it too.", xp->fromModuleName, name, arg->expr->_lineno); } /* ENOENT/ETOOMANYREFS */ @@ -144,10 +145,8 @@ asn1f_lookup_module(arg_t *arg, const char *module_name, asn1p_oid_t *oid) { return NULL; } - - -asn1p_expr_t * -asn1f_lookup_symbol(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) { +static asn1p_expr_t * +asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref, int recursion_depth) { asn1p_expr_t *ref_tc; /* Referenced tc */ asn1p_module_t *imports_from; char *modulename; @@ -170,6 +169,15 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) { mod->ModuleName, ref->_lineno); + if(recursion_depth++ > 30 /* Arbitrary constant */) { + FATAL("Excessive circular referencing detected in module %s for %s at line %d", + mod->ModuleName, + asn1f_printable_reference(ref), + ref->_lineno); + errno = ETOOMANYREFS; + return NULL; + } + if(ref->comp_count == 1) { modulename = NULL; identifier = ref->components[0].name; @@ -247,7 +255,7 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) { assert(tmpref.comp_count > 0); } - expr = asn1f_lookup_symbol(arg, imports_from, &tmpref); + expr = asn1f_lookup_symbol_impl(arg, imports_from, &tmpref, recursion_depth); if(!expr && !(arg->expr->_mark & TM_BROKEN) && !(imports_from->_tags & MT_STANDARD_MODULE)) { arg->expr->_mark |= TM_BROKEN; @@ -327,6 +335,11 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) { asn1p_expr_t * +asn1f_lookup_symbol(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) { + return asn1f_lookup_symbol_impl(arg, mod, ref, 0); +} + +asn1p_expr_t * asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *expr) { return asn1f_find_terminal_thing(arg, expr, FTT_TYPE); } |