From: Arran Cudbard-Bell Date: Wed, 26 Jan 2022 00:33:50 +0000 (-0600) Subject: More scan fixes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cac52b948374ed6b7f7178bffe7248ed2f5dacc4;p=thirdparty%2Ffreeradius-server.git More scan fixes --- diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index de102dc217..0dc12451e2 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -355,9 +355,6 @@ size_t tmpl_pair_list_name(tmpl_pair_list_t *out, char const *name, tmpl_pair_li char const *p = name; char const *q; - /* This should never be a NULL pointer */ - fr_assert(name); - /* * Try and determine the end of the token */ @@ -744,18 +741,18 @@ int tmpl_afrom_value_box(TALLOC_CTX *ctx, tmpl_t **out, fr_value_box_t *data, bo MEM(vpt = talloc(ctx, tmpl_t)); len = fr_value_box_aprint(vpt, &name, data, fr_value_escape_by_quote[quote]); + if (len < 0) { + error: + talloc_free(vpt); + return -1; + } + tmpl_init_shallow(vpt, TMPL_TYPE_DATA, quote, name, len); if (steal) { - if (fr_value_box_steal(vpt, tmpl_value(vpt), data) < 0) { - talloc_free(vpt); - return -1; - } + if (fr_value_box_steal(vpt, tmpl_value(vpt), data) < 0) goto error; } else { - if (fr_value_box_copy(vpt, tmpl_value(vpt), data) < 0) { - talloc_free(vpt); - return -1; - } + if (fr_value_box_copy(vpt, tmpl_value(vpt), data) < 0) goto error; } *out = vpt; diff --git a/src/lib/util/value.h b/src/lib/util/value.h index 658921e221..a231925797 100644 --- a/src/lib/util/value.h +++ b/src/lib/util/value.h @@ -869,17 +869,14 @@ ssize_t fr_value_box_print(fr_sbuff_t *out, fr_value_box_t const *data, fr_sbuf ssize_t fr_value_box_print_quoted(fr_sbuff_t *out, fr_value_box_t const *data, fr_token_t quote) CC_HINT(nonnull); -static inline size_t fr_value_box_aprint(TALLOC_CTX *ctx, char **out, - fr_value_box_t const *data, fr_sbuff_escape_rules_t const *e_rules) -{ - SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(fr_value_box_print, data, e_rules) -} +static inline fr_slen_t fr_value_box_aprint(TALLOC_CTX *ctx, char **out, + fr_value_box_t const *data, fr_sbuff_escape_rules_t const *e_rules) + SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(fr_value_box_print, data, e_rules) + +static inline fr_slen_t fr_value_box_aprint_quoted(TALLOC_CTX *ctx, char **out, + fr_value_box_t const *data, fr_token_t quote) + SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(fr_value_box_print_quoted, data, quote) -static inline size_t fr_value_box_aprint_quoted(TALLOC_CTX *ctx, char **out, - fr_value_box_t const *data, fr_token_t quote) -{ - SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(fr_value_box_print_quoted, data, quote) -} /** @} */ /** @name Hashing *