regcomp issue on alpine, RE_DUP_MAX =255, Fixed by match-all fallback

This commit is contained in:
Olof hagsand 2024-08-14 16:05:40 +02:00
parent bd5214dde1
commit 658ad5504e
2 changed files with 23 additions and 5 deletions

View file

@ -182,6 +182,7 @@ yang_builtin(char *type)
*/ */
static int static int
compile_pattern2regexp(clixon_handle h, compile_pattern2regexp(clixon_handle h,
yang_stmt *ytype,
cvec *patterns, cvec *patterns,
cvec *regexps) cvec *regexps)
{ {
@ -199,10 +200,22 @@ compile_pattern2regexp(clixon_handle h,
if ((ret = regex_compile(h, pattern, &re)) < 0) if ((ret = regex_compile(h, pattern, &re)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
clixon_err(OE_YANG, errno, "regexp compile fail: \"%s\"", yang_stmt *ymod;
clixon_err(OE_YANG, 0, "regexp compile fail: \"%s\"", pattern);
if (regex_free(h, re) < 0)
goto done;
re = NULL;
ymod = ys_module(ytype);
clixon_log(h, LOG_WARNING, "Regexp compile fail: \"%s\" in file %s, fallback using .*",
pattern, yang_filename_get(ymod));
if ((ret = regex_compile(h, ".*", &re)) < 0)
goto done;
if (ret == 0){
clixon_err(OE_YANG, 0, "regexp compile fail: \"%s\"",
pattern); pattern);
goto done; goto done;
break; }
} }
if ((rcv = cvec_add(regexps, CGV_VOID)) == NULL){ if ((rcv = cvec_add(regexps, CGV_VOID)) == NULL){
clixon_err(OE_UNIX, errno, "cvec_add"); clixon_err(OE_UNIX, errno, "cvec_add");
@ -217,6 +230,8 @@ compile_pattern2regexp(clixon_handle h,
} }
retval = 1; retval = 1;
done: done:
if (re != NULL)
retval = regex_free(h, re);
return retval; return retval;
} }
@ -269,7 +284,7 @@ ys_resolve_type(yang_stmt *ytype,
clixon_err(OE_UNIX, errno, "cvec_new"); clixon_err(OE_UNIX, errno, "cvec_new");
goto done; goto done;
} }
if (compile_pattern2regexp(h, patterns, regexps) < 1) if (compile_pattern2regexp(h, ytype, patterns, regexps) < 1)
goto done; goto done;
} }
if (yang_type_cache_set2(ytype, resolved, options, cvv, if (yang_type_cache_set2(ytype, resolved, options, cvv,

View file

@ -83,6 +83,9 @@ if [ $BE -ne 0 ]; then
start_backend -s init -f $cfg start_backend -s init -f $cfg
fi fi
new "wait backend"
wait_backend
new "Set alias" new "Set alias"
expectpart "$($clixon_cli -1f $cfg alias newcmd show config)" 0 "^$" expectpart "$($clixon_cli -1f $cfg alias newcmd show config)" 0 "^$"