From: Arran Cudbard-Bell Date: Thu, 8 Nov 2018 21:58:58 +0000 (-0500) Subject: Print integer strings as integers and not whatever the heck it was doing X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d991dd705addea04f4bf5762064af7d69a6cd1f1;p=thirdparty%2Ffreeradius-server.git Print integer strings as integers and not whatever the heck it was doing --- diff --git a/src/lib/server/xlat_func.c b/src/lib/server/xlat_func.c index 11adb423aee..d3781a6679f 100644 --- a/src/lib/server/xlat_func.c +++ b/src/lib/server/xlat_func.c @@ -173,8 +173,19 @@ static ssize_t xlat_integer(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0; switch (vp->vp_type) { - case FR_TYPE_OCTETS: case FR_TYPE_STRING: + { + fr_value_box_t vb; + + if (fr_value_box_cast(NULL, &vb, FR_TYPE_UINT64, NULL, &vp->data) < 0) { + RPEDEBUG("Input string invalid"); + return -1; + } + + return snprintf(*out, outlen, "%" PRIu64, vb.vb_uint64); + } + + case FR_TYPE_OCTETS: if (vp->vp_length > 8) { break; }