fmt may be NULL. Fixes #1922
authorAlan T. DeKok <aland@freeradius.org>
Fri, 24 Feb 2017 13:11:07 +0000 (08:11 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 24 Feb 2017 13:11:07 +0000 (08:11 -0500)
src/main/realms.c

index 9275512..2a047e0 100644 (file)
@@ -192,10 +192,17 @@ static int home_pool_name_cmp(void const *one, void const *two)
 }
 
 
-static size_t CC_HINT(nonnull) xlat_cs(CONF_SECTION *cs, char const *fmt, char *out, size_t outlen)
+static size_t xlat_cs(CONF_SECTION *cs, char const *fmt, char *out, size_t outlen)
 {
        char const *value = NULL;
 
+       if (!fmt) {
+               DEBUG("No configuration item requested.  Ignoring.");
+
+               *out = '\0';
+               return 0;
+       }
+
        /*
         *      Instance name
         */
@@ -224,8 +231,8 @@ static size_t CC_HINT(nonnull) xlat_cs(CONF_SECTION *cs, char const *fmt, char *
 /*
  *     Xlat for %{home_server:foo}
  */
-static ssize_t CC_HINT(nonnull) xlat_home_server(UNUSED void *instance, REQUEST *request,
-                                                char const *fmt, char *out, size_t outlen)
+static ssize_t xlat_home_server(UNUSED void *instance, REQUEST *request,
+                               char const *fmt, char *out, size_t outlen)
 {
        if (!request->home_server) {
                RWDEBUG("No home_server associated with this request");
@@ -234,6 +241,13 @@ static ssize_t CC_HINT(nonnull) xlat_home_server(UNUSED void *instance, REQUEST
                return 0;
        }
 
+       if (!fmt) {
+               RWDEBUG("No configuration item requested.  Ignoring.");
+
+               *out = '\0';
+               return 0;
+       }
+
        if (strcmp(fmt, "state") == 0) {
                char const *state;
 
@@ -266,8 +280,8 @@ static ssize_t CC_HINT(nonnull) xlat_home_server(UNUSED void *instance, REQUEST
 /*
  *     Xlat for %{home_server_pool:foo}
  */
-static ssize_t CC_HINT(nonnull) xlat_server_pool(UNUSED void *instance, REQUEST *request,
-                                                char const *fmt, char *out, size_t outlen)
+static ssize_t xlat_server_pool(UNUSED void *instance, REQUEST *request,
+                               char const *fmt, char *out, size_t outlen)
 {
        if (!request->home_pool) {
                RWDEBUG("No home_pool associated with this request");
@@ -276,6 +290,13 @@ static ssize_t CC_HINT(nonnull) xlat_server_pool(UNUSED void *instance, REQUEST
                return 0;
        }
 
+       if (!fmt) {
+               RWDEBUG("No configuration item requested.  Ignoring.");
+
+               *out = '\0';
+               return 0;
+       }
+
        if (strcmp(fmt, "state") == 0) {
                char const *state;