From: Arran Cudbard-Bell Date: Thu, 6 Nov 2014 20:12:37 +0000 (-0500) Subject: Fix evaluating IP type check items in the users file X-Git-Tag: branch_3_1_x~4749 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=365857b3ec3bfbc0926e4be06fac31dd3ddfeb26;p=thirdparty%2Ffreeradius-server.git Fix evaluating IP type check items in the users file --- diff --git a/src/main/pair.c b/src/main/pair.c index 4a7e7c32584..18ba6ad6967 100644 --- a/src/main/pair.c +++ b/src/main/pair.c @@ -605,29 +605,38 @@ int paircompare(REQUEST *request, VALUE_PAIR *req_list, VALUE_PAIR *check, */ int radius_xlat_do(REQUEST *request, VALUE_PAIR *vp) { - ssize_t len; - - char buffer[1024]; + ssize_t slen; + char *expanded = NULL; if (vp->type != VT_XLAT) return 0; vp->type = VT_DATA; - len = radius_xlat(buffer, sizeof(buffer), request, vp->value.xlat, NULL, NULL); - + slen = radius_axlat(&expanded, request, vp->value.xlat, NULL, NULL); rad_const_free(vp->value.xlat); vp->value.xlat = NULL; - if (len < 0) { + if (slen < 0) { return -1; } /* * Parse the string into a new value. + * + * If the VALUE_PAIR is being used in a regular expression + * then we just want to copy the new value in unmolested. */ - if (pairparsevalue(vp, buffer, -1) < 0){ + if ((vp->op == T_OP_REG_EQ) || (vp->op == T_OP_REG_NE)) { + pairstrsteal(vp, expanded); + return 0; + } + + if (pairparsevalue(vp, expanded, -1) < 0){ + talloc_free(expanded); return -2; } + talloc_free(expanded); + return 0; }