]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move function needing sbuff out of talloc.c
authorAlan T. DeKok <aland@freeradius.org>
Wed, 11 Mar 2026 21:32:28 +0000 (17:32 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 11 Mar 2026 22:28:36 +0000 (18:28 -0400)
because otherwise we have circular includes of talloc to sbuff
to talloc, and things don't always work as well as they should.

src/lib/kafka/base.c
src/lib/util/file.h
src/lib/util/md4.c
src/lib/util/perm.c
src/lib/util/sbuff.c
src/lib/util/sbuff.h
src/lib/util/talloc.c
src/lib/util/talloc.h

index bd3aaf98934b64014c8fc69b723d54f4a0403484..d6db2f58c7053fb8268a506a6d0fd730d3fd86de 100644 (file)
@@ -462,7 +462,7 @@ static int kafka_config_parse(TALLOC_CTX *ctx, UNUSED void *out, UNUSED void *ba
                        cf_item_mark_parsed(cp_p);
                }
 
-               slen = talloc_array_concat(agg, array, kctx->string_sep);
+               slen = fr_sbuff_array_concat(agg, array, kctx->string_sep);
                talloc_free(array);
                if (slen < 0) return -1;
 
index 80f8bfbbb5c589161d2ec5e9d5cdffcc50a228f0..d4f1a50faeda48e9a6393707db5b73e746337d2b 100644 (file)
@@ -28,7 +28,7 @@ RCSIDH(util_file_h, "$Id$")
 extern "C" {
 #endif
 
-#include <freeradius-devel/util/talloc.h>
+#include <freeradius-devel/util/sbuff.h>
 #include <stdbool.h>
 
 #ifdef HAVE_DIRENT_H
index 7fbfd5196345f1a4eba84d8693d8e138ba53b529..27070e990c51e9b74c8635725ba5ff0c2e0acc84 100644 (file)
@@ -222,6 +222,8 @@ static fr_md4_funcs_t md4_openssl_funcs = {
 /* This is the central step in the MD4 algorithm. */
 #define MD4STEP(f, w, x, y, z, data, s) (w += f(x, y, z) + data, w = w << s | w >> (32 - s))
 
+DIAG_OFF(cast-align)
+
 /** The core of the MD4 algorithm
  *
  * This alters an existing MD4 hash to reflect the addition of 16
index 23acf9056cbf56df2282b1c9e4ef6519d3144f4c..6b25d317c9a16394f7a4b13364c6b666ab0b2dce 100644 (file)
@@ -187,6 +187,8 @@ check:
        return 0;
 }
 
+DIAG_OFF(cast-align)
+
 /** Resolve a uid to a passwd entry
  *
  * Resolves a uid to a passwd entry. The memory to hold the
index d37baed75870ecdf57a1352c528ff6e484f86d28..35ef37812c3a16b48159451fa68b0b2176b92558 100644 (file)
@@ -2317,3 +2317,38 @@ void fr_sbuff_parse_rules_debug(FILE *fp, fr_sbuff_parse_rules_t const *p_rules)
                fprintf(fp, "<none>\n");
        }
 }
+
+/** Concat an array of strings (not NULL terminated), with a string separator
+ *
+ * @param[out] out     Where to write the resulting string.
+ * @param[in] array    of strings to concat.
+ * @param[in] sep      to insert between elements.  May be NULL.
+ * @return
+ *      - >= 0 on success - length of the string created.
+ *     - <0 on failure.  How many bytes we would need.
+ */
+fr_slen_t fr_sbuff_array_concat(fr_sbuff_t *out, char const * const *array, char const *sep)
+{
+       fr_sbuff_t              our_out = FR_SBUFF(out);
+       size_t                  len = talloc_array_length(array);
+       char const * const *    p;
+       char const * const *    end;
+       fr_sbuff_escape_rules_t e_rules = {
+                                       .name = __FUNCTION__,
+                                       .chr = '\\'
+                               };
+
+       if (sep) e_rules.subs[(uint8_t)*sep] = *sep;
+
+       for (p = array, end = array + len;
+            (p < end);
+            p++) {
+               if (*p) FR_SBUFF_RETURN(fr_sbuff_in_escape, &our_out, *p, strlen(*p), &e_rules);
+
+               if (sep && ((p + 1) < end)) {
+                       FR_SBUFF_RETURN(fr_sbuff_in_strcpy, &our_out, sep);
+               }
+       }
+
+       FR_SBUFF_SET_RETURN(out, &our_out);
+}
index 3cba33ebfb3850286bca42ef7c1fe62460792551..83c357265ae14e1eaa579485e3c92f407c7e187a 100644 (file)
@@ -1860,6 +1860,9 @@ void      fr_sbuff_parse_rules_debug(FILE *fp, fr_sbuff_parse_rules_t const *p_rules
  */
 #define fr_sbuff_as_percent_s(_sbuff) (int) fr_sbuff_remaining(_sbuff), fr_sbuff_current(_sbuff)
 
+fr_slen_t  fr_sbuff_array_concat(fr_sbuff_t *out, char const * const *array, char const *sep) CC_HINT(nonnull(1,2));
+
+
 #ifdef __cplusplus
 }
 #endif
index 97a69e1daa8c4c4aa18d85e465a83d149faebbd4..bc2a12488c2f12b006078df9375ece98e19e6b16 100644 (file)
@@ -956,41 +956,6 @@ void **talloc_array_null_strip(void **array)
        return new;
 }
 
-/** Concat an array of strings (not NULL terminated), with a string separator
- *
- * @param[out] out     Where to write the resulting string.
- * @param[in] array    of strings to concat.
- * @param[in] sep      to insert between elements.  May be NULL.
- * @return
- *      - >= 0 on success - length of the string created.
- *     - <0 on failure.  How many bytes we would need.
- */
-fr_slen_t talloc_array_concat(fr_sbuff_t *out, char const * const *array, char const *sep)
-{
-       fr_sbuff_t              our_out = FR_SBUFF(out);
-       size_t                  len = talloc_array_length(array);
-       char const * const *    p;
-       char const * const *    end;
-       fr_sbuff_escape_rules_t e_rules = {
-                                       .name = __FUNCTION__,
-                                       .chr = '\\'
-                               };
-
-       if (sep) e_rules.subs[(uint8_t)*sep] = *sep;
-
-       for (p = array, end = array + len;
-            (p < end);
-            p++) {
-               if (*p) FR_SBUFF_RETURN(fr_sbuff_in_escape, &our_out, *p, strlen(*p), &e_rules);
-
-               if (sep && ((p + 1) < end)) {
-                       FR_SBUFF_RETURN(fr_sbuff_in_strcpy, &our_out, sep);
-               }
-       }
-
-       FR_SBUFF_SET_RETURN(out, &our_out);
-}
-
 /** Callback to free the autofree ctx on global exit
  *
  */
index d0262709a8b32410a8f263ef78e0fe3e712eb233..7bf1956337e221eada373f52881cb3239cebfcc0 100644 (file)
@@ -43,7 +43,6 @@ DIAG_ON(documentation)
 #include <freeradius-devel/autoconf.h> /* Very easy to miss including in special builds */
 #include <freeradius-devel/build.h>
 #include <freeradius-devel/missing.h>
-#include <freeradius-devel/util/sbuff.h>
 
 #undef talloc_autofree_context
 /** The original function is deprecated, so replace it with our version
@@ -249,9 +248,6 @@ void                **talloc_array_null_terminate(void **array);
 
 void           **talloc_array_null_strip(void **array);
 
-fr_slen_t      talloc_array_concat(fr_sbuff_t *out, char const * const *array, char const *sep);
-
-
 /** Free const'd memory
  *
  * @param[in] ptr      to free.