SQL fet_row: error handling

leopold vladimir.belinkis at gs.com
Thu Jun 25 23:08:53 CEST 2009


I noticed an unwanted behavior in rlm_sql.c 
In a while loop that fetches rows the return code of rlm_sql_fetch_row is
not checked properly. 
If rlm_sql_fetch_row returns -1, then sql_get_grouplist should also fail,
but it return 0 instead and in this case rlm_sql module returns "notfound"
instead of "failed". 

Original code: 
int     num_groups = 0; 
.. 
while (rlm_sql_fetch_row(sqlsocket, inst) == 0) { 
... 
} 
(inst->module->sql_finish_select_query)(sqlsocket, inst->config); 

return num_groups; 
-------------------------------- 
It would be nice if you could do something like 
while ((ret=rlm_sql_fetch_row(sqlsocket, inst)) == 0) { 
.. 
} 
if (ret < 0) 
{ 
        /* sql fetch failed */ 
        num_groups = -1; 
} 
(inst->module->sql_finish_select_query)(sqlsocket, inst->config); 

return num_groups;

-- 
View this message in context: http://www.nabble.com/SQL-fet_row%3A-error-handling-tp24211138p24211138.html
Sent from the FreeRadius - User mailing list archive at Nabble.com.




More information about the Freeradius-Users mailing list