From: Alan T. DeKok Date: Sat, 29 Jan 2011 14:44:25 +0000 (+0100) Subject: Fix compile warnings and check for !vp X-Git-Tag: release_2_1_11~136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d994d8b4e03c0f80c6d4140317e972c588fb89f;p=thirdparty%2Ffreeradius-server.git Fix compile warnings and check for !vp --- diff --git a/src/main/xlat.c b/src/main/xlat.c index 6ac45b02dc7..180688c5647 100644 --- a/src/main/xlat.c +++ b/src/main/xlat.c @@ -412,15 +412,15 @@ static size_t xlat_packet(void *instance, REQUEST *request, /* * Print data as integer, not as VALUE. */ -static size_t xlat_integer(void *instance, REQUEST *request, +static size_t xlat_integer(UNUSED void *instance, REQUEST *request, char *fmt, char *out, size_t outlen, - RADIUS_ESCAPE_STRING func) + UNUSED RADIUS_ESCAPE_STRING func) { VALUE_PAIR *vp; while (isspace((int) *fmt)) fmt++; - if (!radius_get_vp(request, fmt, &vp)) { + if (!radius_get_vp(request, fmt, &vp) || !vp) { *out = '\0'; return 0; } @@ -440,9 +440,9 @@ static size_t xlat_integer(void *instance, REQUEST *request, /* * Print data as string, if possible. */ -static size_t xlat_string(void *instance, REQUEST *request, - char *fmt, char *out, size_t outlen, - RADIUS_ESCAPE_STRING func) +static size_t xlat_string(UNUSED void *instance, REQUEST *request, + char *fmt, char *out, size_t outlen, + UNUSED RADIUS_ESCAPE_STRING func) { int len; VALUE_PAIR *vp; @@ -457,10 +457,12 @@ static size_t xlat_string(void *instance, REQUEST *request, if (!radius_get_vp(request, fmt, &vp)) goto nothing; + if (!vp) goto nothing; + if (vp->type != PW_TYPE_OCTETS) goto nothing; *out++ = '"'; - len = fr_print_string(vp->vp_octets, vp->length, out + 1, outlen - 3); + len = fr_print_string(vp->vp_strvalue, vp->length, out + 1, outlen - 3); out[len] = '"'; out[len + 1] = '\0'; @@ -823,7 +825,7 @@ static int decode_attribute(const char **from, char **to, int freespace, RADIUS_ESCAPE_STRING func) { int do_length = 0; - char *xlat_name, *xlat_string; + char *xlat_name, *xlat_str; char *p, *q, *l, *next = NULL; int retlen=0; const xlat_t *c; @@ -976,7 +978,7 @@ static int decode_attribute(const char **from, char **to, int freespace, * or regex reference. */ if (!xlat_name) { - xlat_name = xlat_string = p; + xlat_name = xlat_str = p; goto do_xlat; } @@ -987,7 +989,7 @@ static int decode_attribute(const char **from, char **to, int freespace, RDEBUG2("WARNING: Deprecated conditional expansion \":-\". See \"man unlang\" for details"); p++; - xlat_string = xlat_name; + xlat_str = xlat_name; next = p; goto do_xlat; } @@ -998,13 +1000,13 @@ static int decode_attribute(const char **from, char **to, int freespace, */ /* module name, followed by (possibly) per-module string */ - xlat_string = p; + xlat_str = p; do_xlat: if ((c = xlat_find(xlat_name)) != NULL) { if (!c->internal) RDEBUG3("radius_xlat: Running registered xlat function of module %s for string \'%s\'", - c->module, xlat_string); - retlen = c->do_xlat(c->instance, request, xlat_string, + c->module, xlat_str); + retlen = c->do_xlat(c->instance, request, xlat_str, q, freespace, func); if (retlen > 0) { if (do_length) {