mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-4462 mysqld gets SIGFPE when mysql.user table is empty
avoid divison by zero
This commit is contained in:
8
mysql-test/r/empty_user_table.result
Normal file
8
mysql-test/r/empty_user_table.result
Normal file
@ -0,0 +1,8 @@
|
||||
create table t1 as select * from mysql.user;
|
||||
truncate table mysql.user;
|
||||
flush privileges;
|
||||
connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'u1'@'localhost' (using password: NO)
|
||||
insert mysql.user select * from t1;
|
||||
drop table t1;
|
||||
flush privileges;
|
18
mysql-test/t/empty_user_table.test
Normal file
18
mysql-test/t/empty_user_table.test
Normal file
@ -0,0 +1,18 @@
|
||||
#
|
||||
# MDEV-4462 mysqld gets SIGFPE when mysql.user table is empty
|
||||
#
|
||||
|
||||
source include/not_embedded.inc;
|
||||
|
||||
create table t1 as select * from mysql.user;
|
||||
truncate table mysql.user;
|
||||
flush privileges;
|
||||
|
||||
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
|
||||
--error ER_ACCESS_DENIED_ERROR
|
||||
connect (fail,localhost,u1);
|
||||
|
||||
insert mysql.user select * from t1;
|
||||
drop table t1;
|
||||
flush privileges;
|
||||
|
@ -7367,6 +7367,12 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio, Security_context *sctx)
|
||||
cs->coll->hash_sort(cs, (uchar*) sctx->user, strlen(sctx->user), &nr1, &nr2);
|
||||
|
||||
pthread_mutex_lock(&acl_cache->lock);
|
||||
if (!acl_users.elements)
|
||||
{
|
||||
pthread_mutex_unlock(&acl_cache->lock);
|
||||
login_failed_error(mpvio->thd);
|
||||
return 1;
|
||||
}
|
||||
uint i= nr1 % acl_users.elements;
|
||||
ACL_USER *acl_user_tmp= dynamic_element(&acl_users, i, ACL_USER*);
|
||||
mpvio->acl_user= acl_user_tmp->copy(mpvio->thd->mem_root);
|
||||
|
Reference in New Issue
Block a user