]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
'%' at the end of a string is itself, and not an error
authorAlan T. DeKok <aland@freeradius.org>
Sun, 23 Feb 2025 13:43:45 +0000 (08:43 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 23 Feb 2025 13:43:45 +0000 (08:43 -0500)
src/main/xlat.c

index 4bd0a379cb418e78e148b1fb171fdc3035788e8c..d191f351aac06261fbbfdc16a75cef0570f14c65 100644 (file)
@@ -1509,12 +1509,14 @@ static ssize_t xlat_tokenize_literal(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **he
 
                /*
                 *      Check for valid single-character expansions.
+                *
+                *      Allow '%' at the end of a string as itself.
                 */
-               if (p[0] == '%') {
+               if ((p[0] == '%') && p[1]) {
                        ssize_t slen;
                        xlat_exp_t *next;
 
-                       if (!p[1] || !strchr("%}cdelmntCDGHIMSTYv", p[1])) {
+                       if (!strchr("%}cdelmntCDGHIMSTYv", p[1])) {
                                talloc_free(node);
                                *error = "Invalid variable expansion";
                                p++;