From: Alan T. DeKok Date: Mon, 4 Mar 2019 21:46:37 +0000 (-0500) Subject: manually pull over changes from v3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47f05dc9058904eec5f6fce9b79fbc9dfd039d85;p=thirdparty%2Ffreeradius-server.git manually pull over changes from v3 --- diff --git a/src/modules/rlm_sqlippool/rlm_sqlippool.c b/src/modules/rlm_sqlippool/rlm_sqlippool.c index 3f321f77884..8ede6e13f64 100644 --- a/src/modules/rlm_sqlippool/rlm_sqlippool.c +++ b/src/modules/rlm_sqlippool/rlm_sqlippool.c @@ -296,6 +296,11 @@ static int sqlippool_command(char const *fmt, rlm_sql_handle_t **handle, */ if (!fmt || !*fmt) return 0; + /* + * No handle? That's an error. + */ + if (!handle || !*handle) return -1; + /* * @todo this needs to die (should just be done in xlat expansion) */ @@ -331,7 +336,7 @@ static int sqlippool_command(char const *fmt, rlm_sql_handle_t **handle, * Query the database expecting a single result row */ static int CC_HINT(nonnull (1, 3, 4, 5)) sqlippool_query1(char *out, int outlen, char const *fmt, - rlm_sql_handle_t *handle, rlm_sqlippool_t *data, + rlm_sql_handle_t **handle, rlm_sqlippool_t *data, REQUEST *request, char *param, int param_len) { char query[MAX_QUERY_LEN]; @@ -351,18 +356,18 @@ static int CC_HINT(nonnull (1, 3, 4, 5)) sqlippool_query1(char *out, int outlen, /* * Do an xlat on the provided string */ - if (xlat_aeval(request, &expanded, request, query, data->sql_inst->sql_escape_func, handle) < 0) { + if (xlat_aeval(request, &expanded, request, query, data->sql_inst->sql_escape_func, *handle) < 0) { return 0; } - retval = data->sql_inst->sql_select_query(data->sql_inst, request, &handle, expanded); + retval = data->sql_inst->sql_select_query(data->sql_inst, request, handle, expanded); talloc_free(expanded); - if (retval != 0){ + if ((retval != 0) || !*handle) { REDEBUG("database query error on '%s'", query); return 0; } - if (data->sql_inst->sql_fetch_row(&row, data->sql_inst, request, &handle) < 0) { + if (data->sql_inst->sql_fetch_row(&row, data->sql_inst, request, handle) < 0) { REDEBUG("Failed fetching query result"); goto finish; } @@ -385,8 +390,9 @@ static int CC_HINT(nonnull (1, 3, 4, 5)) sqlippool_query1(char *out, int outlen, strcpy(out, row[0]); retval = rlen; + finish: - (data->sql_inst->driver->sql_finish_select_query)(handle, data->sql_inst->config); + (data->sql_inst->driver->sql_finish_select_query)(*handle, data->sql_inst->config); return retval; } @@ -526,8 +532,9 @@ static rlm_rcode_t CC_HINT(nonnull) mod_post_auth(void *instance, UNUSED void *t DO_PART(allocate_begin); allocation_len = sqlippool_query1(allocation, sizeof(allocation), - inst->allocate_find, handle, + inst->allocate_find, &handle, inst, request, (char *) NULL, 0); + if (!handle) return RLM_MODULE_FAIL; /* * Nothing found... @@ -545,8 +552,9 @@ static rlm_rcode_t CC_HINT(nonnull) mod_post_auth(void *instance, UNUSED void *t *Let's check if the pool exists at all */ allocation_len = sqlippool_query1(allocation, sizeof(allocation), - inst->pool_check, handle, inst, request, + inst->pool_check, &handle, inst, request, (char *) NULL, 0); + if (!handle) return RLM_MODULE_FAIL; fr_pool_connection_release(inst->sql_inst->pool, request, handle);