Treating octets as string

Brian Candler B.Candler at
Fri Jan 28 19:23:31 CET 2011

> > I notice that recently a %{integer:...} expansion was added. Is there
> > perhaps a case for a corresponding %{string:...} expansion?
>   Yes.
>   Editing the dictionaries is not recommended, as it can have additional
> side effects.  Adding %{string:Class} is pretty specific.

OK, I've had a go at a patch. You can find it at

Aside: I guess you can't use this if you have an 'octets' value with an
embedded null. If I set
	Class = 0x666f6f00626172
then Reply-Message = "%{string:Class}" expands to
	Reply-Message = "foo"

Also, while doing this I also discovered a bug in the %{integer:...}
expansion: it will cause freeradius to segfault if the vp is known in the
dictionary but is not present in the request (radius_get_vp will return true
but set vp to NULL).  The fix is also in that branch, but I'll post it here

diff --git a/src/main/xlat.c b/src/main/xlat.c
index 0a02064..f1818e1 100644
--- a/src/main/xlat.c
+++ b/src/main/xlat.c
@@ -420,7 +420,7 @@ static size_t xlat_integer(void *instance, REQUEST *request,
        while (isspace((int) *fmt)) fmt++;
-       if (!radius_get_vp(request, fmt, &vp)) {
+       if (!radius_get_vp(request, fmt, &vp) || !vp) {
                *out = '\0';
                return 0;



More information about the Freeradius-Users mailing list