From: Alan T. DeKok Date: Fri, 24 Feb 2017 13:11:07 +0000 (-0500) Subject: fmt may be NULL. Fixes #1922 X-Git-Tag: release_3_0_13~18 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=freeradius.git;a=commitdiff_plain;h=74d2ecc5c9dad34065040b01cf1228542bb9d89d fmt may be NULL. Fixes #1922 --- diff --git a/src/main/realms.c b/src/main/realms.c index 9275512..2a047e0 100644 --- a/src/main/realms.c +++ b/src/main/realms.c @@ -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;