Skip to content

Commit c855f26

Browse files
committed
various minor bug fixes in compile.c
1 parent 0c1a1ae commit c855f26

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/lib/unlang/compile.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ static int compile_variable(unlang_t *parent, unlang_compile_ctx_t *unlang_ctx,
898898

899899
var->dict = fr_dict_protocol_alloc(unlang_ctx->rules->attr.dict_def);
900900
if (!var->dict) {
901+
group->variables = NULL;
901902
talloc_free(var);
902903
return -1;
903904
}
@@ -1061,9 +1062,10 @@ static bool compile_retry_section(unlang_mod_actions_t *actions, CONF_ITEM *ci)
10611062
CLAMP(max_rtx_time, mrt, 10);
10621063

10631064
} else if (strcmp(name, "max_rtx_count") == 0) {
1064-
unsigned long v = strtoul(value, 0, 0);
1065+
char *end;
1066+
unsigned long v = strtoul(value, &end, 10);
10651067

1066-
if (v > 10) {
1068+
if (*end || (end == value) || (v > 10)) {
10671069
cf_log_err(csi, "Invalid value for 'max_rtx_count = %s' - value must be between 0 and 10",
10681070
value);
10691071
return false;
@@ -2198,7 +2200,6 @@ int unlang_compile(virtual_server_t const *vs,
21982200
CONF_SECTION *cs, unlang_mod_actions_t const *actions, tmpl_rules_t const *rules, void **instruction)
21992201
{
22002202
unlang_t *c;
2201-
tmpl_rules_t my_rules;
22022203
char const *name1, *name2;
22032204
CONF_DATA const *cd;
22042205

@@ -2212,21 +2213,21 @@ int unlang_compile(virtual_server_t const *vs,
22122213
return 1;
22132214
}
22142215

2216+
/*
2217+
* Ensure that all compile functions get valid rules.
2218+
*/
2219+
if (!rules) {
2220+
cf_log_err(cs, "Failed compiling section - no namespace rules passed");
2221+
return -1;
2222+
}
2223+
22152224
name1 = cf_section_name1(cs);
22162225
name2 = cf_section_name2(cs);
22172226

22182227
if (!name2) name2 = "";
22192228

22202229
cf_log_debug(cs, "Compiling policies in - %s %s {...}", name1, name2);
22212230

2222-
/*
2223-
* Ensure that all compile functions get valid rules.
2224-
*/
2225-
if (!rules) {
2226-
memset(&my_rules, 0, sizeof(my_rules));
2227-
rules = &my_rules;
2228-
}
2229-
22302231
c = unlang_compile_section(NULL,
22312232
&(unlang_compile_ctx_t){
22322233
.vs = vs,
@@ -2430,9 +2431,9 @@ static void unlang_perf_dump(fr_log_t *log, unlang_t const *instruction, int dep
24302431
if (!instruction || !instruction->number) return;
24312432

24322433
/*
2433-
* These are generally pushed onto the stack, and therefore ignored.
2434+
* Ignore any non-group instruction.
24342435
*/
2435-
if (instruction->type == UNLANG_TYPE_TMPL) return;
2436+
if (!((instruction->type > UNLANG_TYPE_MODULE) && (instruction->type <= UNLANG_TYPE_POLICY))) return;
24362437

24372438
/*
24382439
* Everything else is an unlang_group_t;

0 commit comments

Comments
 (0)