18402
Bug#58036 client utf32, utf16, ucs2 should be disallowed, they crash server
18404
static void test_bug58036()
18407
DBUG_ENTER("test_bug47485");
18408
myheader("test_bug58036");
18410
/* Part1: try to connect with ucs2 client character set */
18411
conn= mysql_client_init(NULL);
18412
mysql_options(conn, MYSQL_SET_CHARSET_NAME, "ucs2");
18413
if (mysql_real_connect(conn, opt_host, opt_user,
18414
opt_password, opt_db ? opt_db : "test",
18415
opt_port, opt_unix_socket, 0))
18418
printf("mysql_real_connect() succeeded (failure expected)\n");
18424
printf("Got mysql_real_connect() error (expected): %s (%d)\n",
18425
mysql_error(conn), mysql_errno(conn));
18426
DIE_UNLESS(mysql_errno(conn) == ER_WRONG_VALUE_FOR_VAR);
18432
- connect with latin1
18433
- then change client character set to ucs2
18434
- then try mysql_change_user()
18436
conn= mysql_client_init(NULL);
18437
mysql_options(conn, MYSQL_SET_CHARSET_NAME, "latin1");
18438
if (!mysql_real_connect(conn, opt_host, opt_user,
18439
opt_password, opt_db ? opt_db : "test",
18440
opt_port, opt_unix_socket, 0))
18443
printf("mysql_real_connect() failed: %s (%d)\n",
18444
mysql_error(conn), mysql_errno(conn));
18449
mysql_options(conn, MYSQL_SET_CHARSET_NAME, "ucs2");
18450
if (!mysql_change_user(conn, opt_user, opt_password, NULL))
18453
printf("mysql_change_user() succedded, error expected!");
18459
printf("Got mysql_change_user() error (expected): %s (%d)\n",
18460
mysql_error(conn), mysql_errno(conn));
18468
Bug #56976: Severe Denial Of Service in prepared statements
18470
static void test_bug56976()
18473
MYSQL_BIND bind[1];
18475
const char* query = "SELECT LENGTH(?)";
18477
unsigned long i, packet_len = 256 * 1024L;
18478
unsigned long dos_len = 2 * 1024 * 1024L;
18480
DBUG_ENTER("test_bug56976");
18481
myheader("test_bug56976");
18483
stmt= mysql_stmt_init(mysql);
18486
rc= mysql_stmt_prepare(stmt, query, strlen(query));
18487
check_execute(stmt, rc);
18489
memset(bind, 0, sizeof(bind));
18490
bind[0].buffer_type = MYSQL_TYPE_TINY_BLOB;
18492
rc= mysql_stmt_bind_param(stmt, bind);
18493
check_execute(stmt, rc);
18495
long_buffer= (char*) my_malloc(packet_len, MYF(0));
18496
DIE_UNLESS(long_buffer);
18498
memset(long_buffer, 'a', packet_len);
18500
for (i= 0; i < dos_len / packet_len; i++)
18502
rc= mysql_stmt_send_long_data(stmt, 0, long_buffer, packet_len);
18503
check_execute(stmt, rc);
18506
my_free(long_buffer, MYF(0));
18507
rc= mysql_stmt_execute(stmt);
18509
DIE_UNLESS(rc && mysql_stmt_errno(stmt) == ER_UNKNOWN_ERROR);
18511
mysql_stmt_close(stmt);
18517
Bug#13001491: MYSQL_REFRESH CRASHES WHEN STORED ROUTINES ARE RUN CONCURRENTLY.
18519
static void test_bug13001491()
18522
char query[MAX_TEST_QUERY_LENGTH];
18525
myheader("test_bug13001491");
18527
my_snprintf(query, MAX_TEST_QUERY_LENGTH,
18528
"GRANT ALL PRIVILEGES ON *.* TO mysqltest_u1@%s",
18529
opt_host ? opt_host : "'localhost'");
18531
rc= mysql_query(mysql, query);
18534
my_snprintf(query, MAX_TEST_QUERY_LENGTH,
18535
"GRANT RELOAD ON *.* TO mysqltest_u1@%s",
18536
opt_host ? opt_host : "'localhost'");
18538
rc= mysql_query(mysql, query);
18541
c= mysql_client_init(NULL);
18543
DIE_UNLESS(mysql_real_connect(c, opt_host, "mysqltest_u1", NULL,
18544
current_db, opt_port, opt_unix_socket,
18545
CLIENT_MULTI_STATEMENTS |
18546
CLIENT_MULTI_RESULTS));
18548
rc= mysql_query(c, "DROP PROCEDURE IF EXISTS p1");
18552
"CREATE PROCEDURE p1() "
18554
" DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; "
18555
" SELECT COUNT(*) "
18556
" FROM INFORMATION_SCHEMA.PROCESSLIST "
18563
rc= mysql_query(c, "CALL p1()");
18566
mysql_free_result(mysql_store_result(c));
18568
/* Check that mysql_refresh() succeeds without REFRESH_LOG. */
18569
rc= mysql_refresh(c, REFRESH_GRANT |
18570
REFRESH_TABLES | REFRESH_HOSTS |
18571
REFRESH_STATUS | REFRESH_THREADS);
18575
Check that mysql_refresh(REFRESH_LOG) does not crash the server even if it
18576
fails. mysql_refresh(REFRESH_LOG) fails when error log points to unavailable
18579
mysql_refresh(c, REFRESH_LOG);
18581
rc= mysql_query(c, "DROP PROCEDURE p1");
18587
my_snprintf(query, MAX_TEST_QUERY_LENGTH,
18588
"DROP USER mysqltest_u1@%s",
18589
opt_host ? opt_host : "'localhost'");
18591
rc= mysql_query(mysql, query);
18402
18597
Read and parse arguments and MySQL options from my.cnf