From: Alan T. DeKok Date: Sat, 17 Oct 2015 20:45:48 +0000 (-0400) Subject: Fixes for last commit, ported from v3.1.x X-Git-Tag: release_3_0_11~246 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=112eed6f22f99ac4ccc0a43045c2e32e9a998afd;p=thirdparty%2Ffreeradius-server.git Fixes for last commit, ported from v3.1.x --- diff --git a/src/main/parser.c b/src/main/parser.c index abe9db638f4..c80548c23c0 100644 --- a/src/main/parser.c +++ b/src/main/parser.c @@ -1105,21 +1105,24 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st */ if ((c->data.map->lhs->type == TMPL_TYPE_ATTR) && (c->data.map->rhs->type == TMPL_TYPE_LITERAL)) { - PW_TYPE type; + PW_TYPE type = c->data.map->lhs->tmpl_da->type; switch (c->data.map->lhs->tmpl_da->type) { case PW_TYPE_IPV4_ADDR: - type = PW_TYPE_IPV4_PREFIX; - c->cast = dict_attrbyvalue(PW_CAST_BASE + type, 0); + if (strchr(c->data.map->rhs->name, '/') != NULL) { + type = PW_TYPE_IPV4_PREFIX; + c->cast = dict_attrbyvalue(PW_CAST_BASE + type, 0); + } break; case PW_TYPE_IPV6_ADDR: - type = PW_TYPE_IPV6_PREFIX; - c->cast = dict_attrbyvalue(PW_CAST_BASE + type, 0); + if (strchr(c->data.map->rhs->name, '/') != NULL) { + type = PW_TYPE_IPV6_PREFIX; + c->cast = dict_attrbyvalue(PW_CAST_BASE + type, 0); + } break; default: - type = c->data.map->lhs->tmpl_da->type; break; } diff --git a/src/tests/unit/condition.txt b/src/tests/unit/condition.txt index 122f048fc26..536450b4da9 100644 --- a/src/tests/unit/condition.txt +++ b/src/tests/unit/condition.txt @@ -203,7 +203,7 @@ data &Framed-IP-Address <= 192.168.0.0/16 # All IP address literals should be parsed as prefixes condition Framed-IP-Address <= 192.168.0.0/16 -data &Framed-IP-Address <= 192.168.0.0/16 +data &Framed-IP-Address <= 192.168.0.0/16 # string attributes must be string condition User-Name == "bob" @@ -621,10 +621,10 @@ condition &Attr-1 == 'bar' data &User-Name == 'bar' condition &Vendor-11344-Attr-1 == 127.0.0.1 -data &FreeRADIUS-Proxied-To == 127.0.0.1/32 +data &FreeRADIUS-Proxied-To == 127.0.0.1 condition &FreeRADIUS-Attr-1 == 127.0.0.1 -data &FreeRADIUS-Proxied-To == 127.0.0.1/32 +data &FreeRADIUS-Proxied-To == 127.0.0.1 # # Escape the backslashes correctly @@ -670,4 +670,4 @@ condition &NAS-IP-Address < &PMIP6-Home-IPv4-HoA data &NAS-IP-Address < &PMIP6-Home-IPv4-HoA condition &NAS-IP-Address < 192.168/16 -data &Framed-IP-Address <= 192.168.0.0/16 +data &NAS-IP-Address < 192.168.0.0/16