]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Strip error pointer from tmpl_preparse
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 11 Dec 2020 14:52:45 +0000 (07:52 -0700)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 11 Dec 2020 14:53:04 +0000 (07:53 -0700)
src/lib/server/cf_file.c
src/lib/server/cond_tokenize.c
src/lib/server/tmpl.h
src/lib/server/tmpl_tokenize.c

index 937aa41948cf82c02e63012b0cb184bb84218d4c..5fef9c51df84e8b0946cc1147587d0afde040f27 100644 (file)
@@ -796,7 +796,6 @@ static int cf_get_token(CONF_SECTION *parent, char const **ptr_p, fr_token_t *to
 {
        char const *ptr = *ptr_p;
        ssize_t slen;
-       char const *error;
        char const *out;
        size_t outlen;
 
@@ -807,14 +806,14 @@ static int cf_get_token(CONF_SECTION *parent, char const **ptr_p, fr_token_t *to
         *      Don't allow casts or regexes.  But do allow bare
         *      %{...} expansions.
         */
-       slen = tmpl_preparse(&out, &outlen, ptr, strlen(ptr), token, &error, NULL, false, true);
+       slen = tmpl_preparse(&out, &outlen, ptr, strlen(ptr), token, NULL, false, true);
        if (slen <= 0) {
                char *spaces, *text;
 
                fr_canonicalize_error(parent, &spaces, &text, slen, ptr);
 
                ERROR("%s[%d]: %s", filename, lineno, text);
-               ERROR("%s[%d]: %s^ - %s", filename, lineno, spaces, error);
+               ERROR("%s[%d]: %s^ - %s", filename, lineno, spaces, fr_strerror());
 
                talloc_free(spaces);
                talloc_free(text);
index 5005038fd4f50198b3087a0446b3a148a5391b74..668416030326f5abef3d89bf5a2d334f6c10030f 100644 (file)
@@ -237,16 +237,6 @@ static bool cond_type_check(fr_cond_t *c, fr_type_t lhs_type)
        return false;
 }
 
-
-/*
- *     Less code means less bugs
- */
-#define return_P(_x) *error = _x;goto return_p
-#define return_0(_x) *error = _x;goto return_0
-#define return_lhs(_x) *error = _x;goto return_lhs
-#define return_rhs(_x) *error = _x;goto return_rhs
-#define return_SLEN goto return_slen
-
 static ssize_t cond_check_cast(fr_cond_t *c, char const *start,
                               char const *lhs, char const *rhs)
 {
index 37fd4ccab5496486335f87e6635bde8b7b9ded07..71e453c91b627daf689cf7877b8a74493c7c9c9a 100644 (file)
@@ -1010,9 +1010,9 @@ void                      tmpl_extents_debug(fr_dlist_head_t *head);
 /** @} */
 
 ssize_t                        tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t inlen,
-                                     fr_token_t *type, char const **error,
+                                     fr_token_t *type,
                                      fr_dict_attr_t const **castda, bool require_regex,
-                                     bool allow_xlat) CC_HINT(nonnull(1,2,3,5,6));
+                                     bool allow_xlat) CC_HINT(nonnull(1,2,3,5));
 
 bool                   tmpl_async_required(tmpl_t const *vpt);
 
index e97438108861f8f0f89ca7d5038f6c7e7244ef18..692c17eb6c0135f385cc8d8714a1bf8b0e678005 100644 (file)
@@ -4227,7 +4227,7 @@ void tmpl_verify(char const *file, int line, tmpl_t const *vpt)
 }
 #endif
 
-#define return_P(_x) *error = _x;goto return_p
+#define return_P(_x) fr_strerror_const(_x);goto return_p
 
 /** Preparse a string in preparation for passing it to tmpl_afrom_substr()
  *
@@ -4243,7 +4243,6 @@ void tmpl_verify(char const *file, int line, tmpl_t const *vpt)
  * @param      in      where we start looking for the string
  * @param      inlen   length of the input string
  * @param[out] type    token type of the string.
- * @param[out] error   string describing the error
  * @param[out] castda  NULL if casting is not allowed, otherwise the cast
  * @param   require_regex whether or not to require regular expressions
  * @param   allow_xlat  whether or not "bare" xlat's are allowed
@@ -4252,7 +4251,7 @@ void tmpl_verify(char const *file, int line, tmpl_t const *vpt)
  *     - <=0, -offset in 'start' where the parse error was located
  */
 ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t inlen,
-                     fr_token_t *type, char const **error,
+                     fr_token_t *type,
                      fr_dict_attr_t const **castda, bool require_regex, bool allow_xlat)
 {
        char const *p = in, *end = in + inlen;
@@ -4270,7 +4269,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t i
                char const *q;
 
                if (!castda) {
-                       *error = "Unexpected cast";
+                       fr_strerror_const("Unexpected cast");
                return_p:
                        return -(p - in);
                }