[unixODBC-dev] A bug in release_env function

xiaonan xn212516 at 163.com
Thu Jul 25 10:45:14 BST 2013


Hi, Nick:


Greetings form me!
I found a issue in release_env function. In this function, the env_lib_list is a local varibale, but it points to a gloabl variable connection -> environment -> env_lib_list. So I think the whole code should be protected like this:


static void release_env( DMHDBC connection )
{
struct env_lib_struct *env_lib_list, *env_lib_prev;
int ret;


if ( connection -> driver_env )
{
mutex_lib_entry();
 
......
 
mutex_lib_exit();
}
}
If not add the mutex in release_env, there will be a thread calls __connect_part_one, which accesses the connection -> environment -> env_lib_list, while the other thread calls release_env, which also accesses the connection -> environment -> env_lib_list. And this will cause unpredictable result, such as core dump.
Please check it, thanks very much!
Best Regards
Nan Xiao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-dev/attachments/20130725/f23e414e/attachment.html>


More information about the unixODBC-dev mailing list