Skip to content

Commit 7234f7b

Browse files
committed
fix uses of fr_sbuff_marker() vs fr_sbuff_set()
fr_sbuff_marker() is run once, and only once. after that, fr_sbuff_set() is used to update the marker
1 parent 6d89b69 commit 7234f7b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/lib/util/pair_legacy.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,13 @@ fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t
380380
fr_dict_attr_unknown_free(&da_stack.da[i]); \
381381
} } } while (0)
382382

383+
/*
384+
* Initialize the markers once, before the redo label, so that they are only inserted into the
385+
* marker linked list once. After this, use fr_sbuff_set() to update marker positions.
386+
*/
387+
fr_sbuff_marker(&lhs_m, &our_in);
388+
fr_sbuff_marker(&op_m, &our_in);
389+
fr_sbuff_marker(&rhs_m, &our_in);
383390

384391
redo:
385392
raw = false;
@@ -466,7 +473,7 @@ fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t
466473
/*
467474
* Set the LHS marker to be after any initial '.'
468475
*/
469-
fr_sbuff_marker(&lhs_m, &our_in);
476+
fr_sbuff_set(&lhs_m, &our_in);
470477

471478
/*
472479
* STEP 2: Find and check the operator.
@@ -484,7 +491,7 @@ fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t
484491
*/
485492
if (!components) goto done;
486493

487-
fr_sbuff_marker(&op_m, &our_in);
494+
fr_sbuff_set(&op_m, &our_in);
488495
fr_sbuff_adv_past_blank(&our_in, SIZE_MAX, NULL);
489496

490497
/*
@@ -577,7 +584,9 @@ fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t
577584
raw_type = FR_TYPE_OCTETS;
578585

579586
} else if (fr_sbuff_next_if_char(&our_in, '(')) {
580-
fr_sbuff_marker(&rhs_m, &our_in);
587+
fr_sbuff_marker_t cast_m;
588+
589+
fr_sbuff_marker(&cast_m, &our_in);
581590

582591
fr_sbuff_out_by_longest_prefix(&slen, &raw_type, fr_type_table, &our_in, FR_TYPE_NULL);
583592

@@ -586,7 +595,7 @@ fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t
586595
* TLV. Instead, the value should just start with '{'.
587596
*/
588597
if (!fr_type_is_leaf(raw_type)) {
589-
fr_sbuff_set(&our_in, &rhs_m);
598+
fr_sbuff_set(&our_in, &cast_m);
590599
fr_strerror_const("Invalid data type in cast");
591600
goto error;
592601
}
@@ -607,7 +616,7 @@ fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t
607616
}
608617
}
609618

610-
fr_sbuff_marker(&rhs_m, &our_in);
619+
fr_sbuff_set(&rhs_m, &our_in);
611620

612621
fr_sbuff_set(&our_in, &lhs_m);
613622

@@ -641,7 +650,7 @@ fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t
641650
goto error;
642651
}
643652

644-
fr_sbuff_marker(&lhs_m, &our_in);
653+
fr_sbuff_set(&lhs_m, &our_in);
645654

646655
/*
647656
* The fr_pair_t parent might be a group, in which case the fr_dict_attr_t parent will be

0 commit comments

Comments
 (0)