Skip to content

Commit 89a8a6a

Browse files
authored
Merge branch 'vlm_master' into copilot/fix-child-type-selection-issue-again
2 parents 45c31c7 + ac1e6ee commit 89a8a6a

File tree

6 files changed

+935
-7
lines changed

6 files changed

+935
-7
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
ambiguity. Affects 3GPP RRC and similar specifications with duplicate member
1010
names across different parent structures.
1111
(Severity: high; Security impact: none)
12+
* Moved complex_threshold from global variable to arg_t structure field.
13+
Applications linking to libasn1compiler no longer need to define their own
14+
version of the global complex_threshold variable. The variable is now properly
15+
encapsulated within the compiler's argument structure and passed through the
16+
asn1_compile() function. Default threshold value remains 4. Added test case
17+
for -fcomplex-threshold flag validation.
18+
(Severity: low; Security impact: none)
1219
* Fixed JER OPEN TYPE decoder to comply with ITU-T X.697 Clause 41. The decoder
1320
was incorrectly attempting to parse CHOICE-style key wrappers and consuming
1421
parent SEQUENCE delimiters, causing "Unexpected JSON key" and "Out of defined

asn1c/asn1c.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ is_integer(const char *str, long *out_val) {
8484
static void usage(const char *av0); /* Print the Usage screen and exit */
8585
static int importStandardModules(asn1p_t *asn, const char *skeletons_dir);
8686

87-
int complex_threshold = 4; /* threshold after which complex_level is true (DIRTY HACK) */
87+
8888

8989
int
9090
main(int ac, char **av) {
@@ -105,6 +105,7 @@ main(int ac, char **av) {
105105
int ch; /* Command line character */
106106
int i; /* Index in some loops */
107107
int exit_code = 0; /* Exit code */
108+
int complex_threshold = 4; /* Threshold for switching structures to ptrs */
108109

109110
/*
110111
* Process command-line options.
@@ -492,7 +493,8 @@ main(int ac, char **av) {
492493
* of another language.
493494
*/
494495
if(asn1_compile(asn, skeletons_dir, destdir ? destdir : "",
495-
asn1_compiler_flags, ac + optind, optind, av - optind)) {
496+
asn1_compiler_flags, ac + optind, optind, av - optind,
497+
complex_threshold)) {
496498
exit_code = EX_SOFTWARE;
497499
}
498500

libasn1compiler/asn1c_C.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4439,7 +4439,6 @@ emit_include_dependencies(arg_t *arg) {
44394439
return 0;
44404440
}
44414441

4442-
extern int complex_threshold; // defined in asn1c/asn1c.c - need fixing
44434442
/*
44444443
* Check if it is better to make this type indirectly accessed via
44454444
* a pointer.
@@ -4529,10 +4528,11 @@ expr_break_recursion(arg_t *arg, asn1p_expr_t *expr) {
45294528
/* If the terminal has 4 or more complex members, use indirection
45304529
* to avoid excessive nesting and potential circular dependencies
45314530
* that might not be caught by simple recursion detection.
4532-
* This threshold is chosen to avoid breaking existing test expectations
4531+
* This threshold is configurable via -fcomplex-threshold flag
4532+
* (default: 4) and is chosen to avoid breaking existing test expectations
45334533
* while still handling deeply nested structures like F1AP's SRSConfig.
45344534
*/
4535-
if(complex_members >= complex_threshold) {
4535+
if(complex_members >= arg->complex_threshold) {
45364536
expr->marker.flags |= EM_INDIRECT;
45374537
expr->marker.flags |= EM_UNRECURSE;
45384538
return 1;

libasn1compiler/asn1compiler.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static void asn1c_mark_ioc_table_dependencies(arg_t *arg, asn1p_ioc_table_t *ioc
1616

1717
int
1818
asn1_compile(asn1p_t *asn, const char *datadir, const char *destdir, enum asn1c_flags flags,
19-
int argc, int optc, char **argv) {
19+
int argc, int optc, char **argv, int complex_threshold) {
2020
arg_t arg_s = {0};
2121
arg_t *arg = &arg_s;
2222
asn1p_module_t *mod;
@@ -35,6 +35,7 @@ asn1_compile(asn1p_t *asn, const char *datadir, const char *destdir, enum asn1c_
3535
arg->logger_cb = default_logger_cb;
3636
arg->flags = flags;
3737
arg->asn = asn;
38+
arg->complex_threshold = complex_threshold;
3839

3940
/*
4041
* If -flist-deps is specified, list dependencies and exit

libasn1compiler/asn1compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ enum asn1c_flags {
144144
* Compile the ASN.1 specification.
145145
*/
146146
int asn1_compile(asn1p_t *asn, const char *datadir, const char *destdir, enum asn1c_flags,
147-
int argc, int optc, char **argv);
147+
int argc, int optc, char **argv, int complex_threshold);
148148

149149
void asn1c_debug_type_naming(asn1p_t *asn, enum asn1c_flags,
150150
char **asn_type_names);

0 commit comments

Comments
 (0)