From: Arran Cudbard-Bell Date: Wed, 5 Nov 2014 22:36:29 +0000 (-0500) Subject: Fix for if ("%{Tmp-Integer-0}" =~ /"%{Tmp-Integer-0}"/ X-Git-Tag: branch_3_1_x~4764 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f7edc0d79375dca9d24232ed66309ef99928f5d3;p=thirdparty%2Ffreeradius-server.git Fix for if ("%{Tmp-Integer-0}" =~ /"%{Tmp-Integer-0}"/ and other minor issues --- diff --git a/src/main/evaluate.c b/src/main/evaluate.c index 9f773e37cfe..29ce8723f14 100644 --- a/src/main/evaluate.c +++ b/src/main/evaluate.c @@ -440,7 +440,7 @@ static int cond_normalise_values(REQUEST *request, fr_cond_t const *c, value_pair_map_t const *map = c->data.map; DICT_ATTR const *cast = NULL; - PW_TYPE cast_type = PW_TYPE_STRING; + PW_TYPE cast_type = PW_TYPE_INVALID; int rcode; @@ -462,9 +462,7 @@ static int cond_normalise_values(REQUEST *request, fr_cond_t const *c, */ #define CAST(_s) \ do {\ - if (!cast && lhs && rhs && (lhs_type == PW_TYPE_STRING) && (rhs_type == PW_TYPE_STRING) &&\ - all_digits(lhs->strvalue) && all_digits(rhs->strvalue)) cast_type = PW_TYPE_INTEGER64;\ - if ((cast_type != _s ## _type) && (_s ## _type != PW_TYPE_INVALID)) {\ + if ((cast_type != PW_TYPE_INVALID) && (_s ## _type != PW_TYPE_INVALID) && (cast_type != _s ## _type)) {\ ssize_t r;\ EVAL_DEBUG("CASTING " #_s " FROM %s TO %s",\ fr_int2str(dict_attr_types, _s ## _type, ""),\ @@ -482,6 +480,17 @@ do {\ }\ } while (0) +#define CHECK_INT_CAST(_l, _r) \ +do {\ + if ((cast_type == PW_TYPE_INVALID) &&\ + _l && (_l ## _type == PW_TYPE_STRING) &&\ + _r && (_r ## _type == PW_TYPE_STRING) &&\ + all_digits(lhs->strvalue) && all_digits(rhs->strvalue)) {\ + cast_type = PW_TYPE_INTEGER64;\ + EVAL_DEBUG("OPERANDS ARE NUMBER STRINGS, SETTING CAST TO integer64");\ + }\ +} while (0) + /* * Regular expressions need both operands to be strings */ @@ -533,6 +542,7 @@ do {\ rhs = &vp->data; rhs_len = vp->length; + CHECK_INT_CAST(lhs, rhs); CAST(lhs); CAST(rhs); @@ -549,6 +559,7 @@ do {\ rhs = &map->rhs->tmpl_data_value; rhs_len = map->rhs->tmpl_data_length; + CHECK_INT_CAST(lhs, rhs); CAST(lhs); CAST(rhs); @@ -577,6 +588,7 @@ do {\ rhs_type = PW_TYPE_STRING; rhs = &data; + CHECK_INT_CAST(lhs, rhs); CAST(lhs); CAST(rhs); diff --git a/src/modules/rlm_example/rlm_example.c b/src/modules/rlm_example/rlm_example.c index c0c78c02dbf..ac866d46af1 100644 --- a/src/modules/rlm_example/rlm_example.c +++ b/src/modules/rlm_example/rlm_example.c @@ -89,7 +89,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance) } if (dict_addattr("Example-Paircmp", -1, 0, PW_TYPE_STRING, flags) < 0) { - ERROR("Failed creating paircmp attribute", fr_strerror()); + ERROR("Failed creating paircmp attribute: %s", fr_strerror()); return -1; }