From: Arran Cudbard-Bell Date: Tue, 30 Jun 2015 17:15:33 +0000 (-0400) Subject: Explicitly prevent the use of URLs if we don't have URL parsing functions X-Git-Tag: release_3_0_9~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=843c466ef97339fcdaf2d2d924681bab14fcbc78;p=thirdparty%2Ffreeradius-server.git Explicitly prevent the use of URLs if we don't have URL parsing functions --- diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index 1dc7feaf81b..010206c72e8 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -966,22 +966,27 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance) port = inst->port; + /* + * We don't support URLs if the library didn't provide + * URL parsing functions. + */ + if (strchr(value, '/')) { + bad_server_fmt: + cf_log_err_cp(cp, "Invalid server value, must be in format [:]"); + return -1; + } + p = strrchr(value, ':'); if (p) { port = (int)strtol((p + 1), &q, 10); - if ((p == value) || ((p + 1) == q) || (*q != '\0')) { - cf_log_err_cp(cp, "Invalid server, must be in [:] format"); - return -1; - } + if ((p == value) || ((p + 1) == q) || (*q != '\0')) goto bad_server_fmt; len = p - value; } else { len = strlen(value); } - if (port == 0) port = LDAP_PORT; - inst->server = talloc_asprintf_append(inst->server, "ldap://%.*s:%i ", - (int) len, value, port); + inst->server = talloc_asprintf_append(inst->server, "ldap://%.*s:%i ", (int) len, value, port); #else /* * ldap_init takes port, which can be overridden by :port so