]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
minor tweaks
authorAlan T. DeKok <aland@freeradius.org>
Sun, 29 Oct 2023 15:28:05 +0000 (11:28 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 29 Oct 2023 15:28:05 +0000 (11:28 -0400)
keep going on ,<CR>, too.

produce better error messages when the child attribute is not
found.

src/lib/util/pair_legacy.c
src/tests/unit/file_unflatten.txt [deleted file]

index b0013143e5bd9fd269dbd9a6aca651813c23aa34..c0193f070bf445d4408da9bf72ea2348450551cf 100644 (file)
@@ -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 (file)
index 5fa34c1..0000000
+++ /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