numaffected = (inst->module->sql_affected_rows)(handle, inst->config);
if (numaffected < 1) {
RDEBUG("SQL query affected no rows");
+ (inst->module->sql_finish_query)(handle, inst->config);
goto finish;
}
if (rcode != RLM_SQL_OK) goto query_error;
rcode = rlm_sql_fetch_row(inst, request, &handle);
- if (rcode) goto query_error;
+ if (rcode) {
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ goto query_error;
+ }
row = handle->row;
if (!row) {
if (rlm_sql_select_query(inst, NULL, &handle, inst->config->client_query) != RLM_SQL_OK) return -1;
while ((rlm_sql_fetch_row(inst, NULL, &handle) == 0) && (row = handle->row)) {
+ int num_rows;
char *server = NULL;
+
i++;
+ num_rows = (inst->module->sql_num_fields)(handle, inst->config);
+ if (num_rows < 5) {
+ WARN("SELECT returned too few rows. Please do not edit 'client_query'");
+ continue;
+ }
+
/*
* The return data for each row MUST be in the following order:
*
continue;
}
- if (((inst->module->sql_num_fields)(handle, inst->config) > 5) && (row[5] != NULL) && *row[5]) {
+ if ((num_rows > 5) && (row[5] != NULL) && *row[5]) {
server = row[5];
}
fr_pair_value_strsteal(vp, expanded);
RDEBUG2("SQL-User-Name set to '%s'", vp->vp_strvalue);
- vp->op = T_OP_SET;
+ vp->op = T_OP_SET;
/*
* Delete any existing SQL-User-Name, and replace it with ours.
*
* We need this to check if the sql_fields callback is provided.
*/
- inst->handle = lt_dlopenext(inst->config->sql_driver_name);
+ inst->handle = fr_dlopenext(inst->config->sql_driver_name);
if (!inst->handle) {
ERROR("Could not link driver %s: %s", inst->config->sql_driver_name, fr_strerror());
ERROR("Make sure it (and all its dependent libraries!) are in the search path of your system's ld");
}
while (rlm_sql_fetch_row(inst, request, &handle) == 0) {
+ int num_rows;
+
row = handle->row;
if (!row) {
break;
}
+ num_rows = (inst->module->sql_num_fields)(handle, inst->config);
+ if (num_rows < 8) {
+ RDEBUG("Too few rows returned. Please do not edit 'simul_verify_query'");
+ rcode = RLM_MODULE_FAIL;
+
+ goto finish;
+ }
+
if (!row[2]){
RDEBUG("Cannot zap stale entry. No username present in entry");
rcode = RLM_MODULE_FAIL;
else if (strcmp(row[7], "SLIP") == 0)
proto = 'S';
}
- if (row[8])
+ if ((num_rows > 8) && row[8])
sess_time = atoi(row[8]);
session_zap(request, nas_addr, nas_port,
row[2], row[1], framed_addr,