From: Alan T. DeKok Date: Sun, 29 Oct 2023 15:28:05 +0000 (-0400) Subject: minor tweaks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d00b55f2738ff70b12ae77b338c54510fdeeaebf;p=thirdparty%2Ffreeradius-server.git minor tweaks keep going on ,, too. produce better error messages when the child attribute is not found. --- diff --git a/src/lib/util/pair_legacy.c b/src/lib/util/pair_legacy.c index b0013143e5b..c0193f070bf 100644 --- a/src/lib/util/pair_legacy.c +++ b/src/lib/util/pair_legacy.c @@ -138,6 +138,7 @@ fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t bool raw, raw_octets; bool was_relative = false; bool append; + bool keep_going; fr_token_t op; fr_slen_t slen; fr_pair_t *vp; @@ -297,11 +298,7 @@ redo: goto update_relative; } - /* - * @todo - it isn't found, return a descriptive error. - */ - fr_strerror_printf("Unknown child attribute for parent %s", relative->da->name); - return fr_sbuff_error(&our_in); + goto notfound; } if (internal) { @@ -310,8 +307,14 @@ redo: } if (err != FR_DICT_ATTR_OK) { - fr_strerror_printf("Unknown child attribute for parent %s", relative->da->name); - return fr_sbuff_error(&our_in) + slen; + notfound: + fr_sbuff_marker(&rhs_m, &our_in); + fr_sbuff_adv_past_allowed(&our_in, SIZE_MAX, fr_dict_attr_allowed_chars, NULL); + + fr_strerror_printf("Unknown attribute \"%.*s\" for parent \"%s\"", + (int) fr_sbuff_diff(&our_in, &rhs_m), fr_sbuff_current(&rhs_m), + relative->da->name); + return fr_sbuff_error(&our_in); } fr_assert(da != NULL); @@ -501,15 +504,19 @@ redo: done: PAIR_VERIFY(vp); - if (fr_sbuff_next_if_char(&our_in, ',')) goto redo; + keep_going = fr_sbuff_next_if_char(&our_in, ','); if (relative->allow_crlf) { size_t len; len = fr_sbuff_adv_past_allowed(&our_in, SIZE_MAX, sbuff_char_line_endings, NULL); - if (len > 0) goto redo; + keep_going |= (len > 0); } + keep_going &= (fr_sbuff_remaining(&our_in) > 0); + + if (keep_going) goto redo; + FR_SBUFF_SET_RETURN(in, &our_in); } diff --git a/src/tests/unit/file_unflatten.txt b/src/tests/unit/file_unflatten.txt deleted file mode 100644 index 5fa34c100fb..00000000000 --- a/src/tests/unit/file_unflatten.txt +++ /dev/null @@ -1,35 +0,0 @@ -# -# Tests for parsing files ala radclient or "users" -# -# $Id$ -# - -proto-dictionary radius - -# -# Fully specified paths. -# -read_file files/cisco_avpair.txt -match User-Name = "bob", User-Password = "hello", Vendor-Specific = { Cisco = { AVPair = "1", AVPair += "2", AVPair += "3", AVPair += "4" } } - -# -# Relative attributes, all on the same line. -# -read_file files/cisco_relative.txt -match User-Name = "bob", User-Password = "hello", Vendor-Specific = { Cisco = { AVPair = "1", AVPair += "2", AVPair += "3", AVPair += "4" } } - -# -# Relative attributes, each on a different line -# -read_file files/cisco_multiline_relative.txt -match User-Name = "bob", User-Password = "hello", Vendor-Specific = { Cisco = { AVPair = "1", AVPair += "2", AVPair += "3", AVPair += "4" } } - - -# -# Multiple Cisco AVPAir, all on one line -# -read_file files/cisco_single_line.txt -match User-Name = "bob", User-Password = "hello", Vendor-Specific = { Cisco = { AVPair = "1", AVPair += "2", AVPair += "3", AVPair += "4" } } - -count -match 9