]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
start of cleaning up escaping rules
authorAlan T. DeKok <aland@freeradius.org>
Sun, 15 Oct 2023 13:35:37 +0000 (09:35 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 15 Oct 2023 13:37:28 +0000 (09:37 -0400)
note that fr_value_box_print() does NOT respect tainting

fix a few callers to just re-implement print_quoted()

src/lib/unlang/xlat_tokenize.c
src/lib/util/pair_print.c
src/lib/util/value.c

index f49de2ef83605a2cfd8fa69d86af44334e1c258e..256dc4ae9e8b3b06f0a2fb1c3b3b586a0700d87f 100644 (file)
@@ -1460,9 +1460,7 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t
                if (node->quote == T_BARE_WORD) {
                        FR_SBUFF_RETURN(fr_value_box_print, out, &node->data, e_rules);
                } else {
-                       FR_SBUFF_IN_CHAR_RETURN(out, fr_token_quote[node->quote]);
-                       FR_SBUFF_RETURN(fr_value_box_print, out, &node->data, fr_value_escape_by_quote[node->quote]);
-                       FR_SBUFF_IN_CHAR_RETURN(out, fr_token_quote[node->quote]);
+                       FR_SBUFF_RETURN(fr_value_box_print_quoted, out, &node->data, node->quote);
                }
                goto done;
 
index db6ec888cc7313f86bb9c9f1ee466989b0da8d0d..b7877b5d8cb4be92071af6f253c675ba1af33b22 100644 (file)
@@ -167,9 +167,7 @@ ssize_t fr_pair_print_secure(fr_sbuff_t *out, fr_dict_attr_t const *parent, fr_p
                        FALL_THROUGH;
 
                case FR_TYPE_DATE:
-                       FR_SBUFF_IN_CHAR_RETURN(&our_out, '"');
-                       FR_SBUFF_RETURN(fr_value_box_print, &our_out, &vp->data, &fr_value_escape_double);
-                       FR_SBUFF_IN_CHAR_RETURN(&our_out, '"');
+                       FR_SBUFF_RETURN(fr_value_box_print_quoted, &our_out, &vp->data, T_DOUBLE_QUOTED_STRING);
                        break;
 
                case FR_TYPE_OCTETS:
index b2836df3da68a6a2c03ce1f5166b8db69c26f25c..5eefaeb1288e97f655a76aa342bcb1a4c0d9dc19 100644 (file)
@@ -5113,9 +5113,12 @@ ssize_t fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst,
  * in a database, in all other instances it's better to use
  * #fr_value_box_print_quoted.
  *
+ * @note - this function does NOT respect tainting!  The escaping rules
+ * are ONLY for escaping quotation characters, CR, LF, etc.
+ *
  * @param[in] out      Where to write the printed string.
  * @param[in] data     Value box to print.
- * @param[in] e_rules  To apply to FR_TYPE_STRING types.
+ * @param[in] e_rules  To apply to FR_TYPE_STRING types, for escaping quotation characters _only_.
  *                     Is not currently applied to any other box type.
  */
 ssize_t fr_value_box_print(fr_sbuff_t *out, fr_value_box_t const *data, fr_sbuff_escape_rules_t const *e_rules)