From 75f54100c652fdd3ec45e73b10fff3ebd94c4e5e Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Mon, 25 Oct 2021 14:17:19 -0400 Subject: [PATCH] Assert that *out isn't set if the substr parsers return an error --- src/lib/server/tmpl_tokenize.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index d3bf4d61ac2..24a6acd8445 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -2545,12 +2545,14 @@ ssize_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out, return fr_sbuff_set(in, &our_in); } + fr_assert(!*out); /* * See if it's an octets string */ slen = tmpl_afrom_octets_substr(ctx, out, &our_in, p_rules); if (slen > 0) goto done_bareword; + fr_assert(!*out); /* * See if it's a mac address @@ -2561,18 +2563,21 @@ ssize_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out, */ slen = tmpl_afrom_ether_substr(ctx, out, &our_in, p_rules); if (slen > 0) goto done_bareword; + fr_assert(!*out); /* * See if it's an IPv4 address or prefix */ slen = tmpl_afrom_ipv4_substr(ctx, out, &our_in, p_rules); if (slen > 0) goto done_bareword; + fr_assert(!*out); /* * See if it's an IPv6 address or prefix */ slen = tmpl_afrom_ipv6_substr(ctx, out, &our_in, p_rules); if (slen > 0) goto done_bareword; + fr_assert(!*out); /* * See if it's a float @@ -2586,6 +2591,7 @@ ssize_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out, */ slen = tmpl_afrom_integer_substr(ctx, out, &our_in, p_rules); if (slen > 0) goto done_bareword; + fr_assert(!*out); /* * See if it's an attribute reference @@ -2593,6 +2599,7 @@ ssize_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out, */ slen = tmpl_afrom_attr_substr(ctx, NULL, out, &our_in, p_rules, t_rules); if (slen > 0) goto done_bareword; + fr_assert(!*out); vpt = tmpl_alloc_null(ctx); -- 2.47.3