From: Alan T. DeKok Date: Thu, 12 Sep 2019 14:23:17 +0000 (-0400) Subject: more fixes for parser X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a189c2159480ddfc0bfb02c411833de4e24be031;p=thirdparty%2Ffreeradius-server.git more fixes for parser allow more characters if we don't use regex, treat '/' as a normal string --- diff --git a/src/lib/server/tmpl.c b/src/lib/server/tmpl.c index b1cdc0c6621..5afc99cb111 100644 --- a/src/lib/server/tmpl.c +++ b/src/lib/server/tmpl.c @@ -3072,6 +3072,8 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start, return_P("Unterminated expansion"); case '/': + if (!require_regex) goto bare_word; + quote = *(p++); *type = T_OP_REG_EQ; goto skip_string; @@ -3136,6 +3138,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start, goto skip_word; default: + bare_word: *out = p; quote = '\0'; @@ -3155,6 +3158,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start, if (p[1] == '{') { p += 2; depth++; + continue; } else if ((p[1] == 'E') && (p[2] == 'N') && @@ -3162,6 +3166,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start, (p[4] == '{')) { p += 5; depth++; + continue; } else { /* @@ -3171,6 +3176,17 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start, } } + if (*p == '%') { + if (p[1] == '{') { + p += 2; + depth++; + continue; + } + + p++; + continue; + } + /* * If we're inside of a ${...} expansion, * then allow everything until the @@ -3206,9 +3222,18 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start, /* * Allowed in attribute names, and/or - * host names and IP addresses. + * host names and IP addresses, and IPv6 addresses. + */ + if ((*p == '.') || (*p == '/') || (*p == '_') || (*p == '*') || + (*p == ']')) { + p++; + continue; + } + + /* + * [...] is an IPv6 address. */ - if ((*p == '.') || (*p == '/') || (*p == '_')) { + if ((p == start) && (*p == '[')) { p++; continue; } @@ -3245,6 +3270,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start, */ if ((*p == '#') || (*p == '*') || (*p == 'n')) { p++; + } else { /* * Allow numbers as array indexes