]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix compile warnings and check for !vp
authorAlan T. DeKok <aland@freeradius.org>
Sat, 29 Jan 2011 14:44:25 +0000 (15:44 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 29 Jan 2011 14:44:25 +0000 (15:44 +0100)
src/main/xlat.c

index 6ac45b02dc7c4f32cf6a0b0aea48c22d6a1b9aa9..180688c56472320b74df7fa043f2f3ff4a9f1a20 100644 (file)
@@ -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) {