mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Updated/added copyright headers
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -18398,6 +18398,122 @@ static void test_bug47485()
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Bug#58036 client utf32, utf16, ucs2 should be disallowed, they crash server
|
||||
*/
|
||||
static void test_bug58036()
|
||||
{
|
||||
MYSQL *conn;
|
||||
DBUG_ENTER("test_bug47485");
|
||||
myheader("test_bug58036");
|
||||
|
||||
/* Part1: try to connect with ucs2 client character set */
|
||||
conn= mysql_client_init(NULL);
|
||||
mysql_options(conn, MYSQL_SET_CHARSET_NAME, "ucs2");
|
||||
if (mysql_real_connect(conn, opt_host, opt_user,
|
||||
opt_password, opt_db ? opt_db : "test",
|
||||
opt_port, opt_unix_socket, 0))
|
||||
{
|
||||
if (!opt_silent)
|
||||
printf("mysql_real_connect() succeeded (failure expected)\n");
|
||||
mysql_close(conn);
|
||||
DIE("");
|
||||
}
|
||||
|
||||
if (!opt_silent)
|
||||
printf("Got mysql_real_connect() error (expected): %s (%d)\n",
|
||||
mysql_error(conn), mysql_errno(conn));
|
||||
DIE_UNLESS(mysql_errno(conn) == ER_WRONG_VALUE_FOR_VAR);
|
||||
mysql_close(conn);
|
||||
|
||||
|
||||
/*
|
||||
Part2:
|
||||
- connect with latin1
|
||||
- then change client character set to ucs2
|
||||
- then try mysql_change_user()
|
||||
*/
|
||||
conn= mysql_client_init(NULL);
|
||||
mysql_options(conn, MYSQL_SET_CHARSET_NAME, "latin1");
|
||||
if (!mysql_real_connect(conn, opt_host, opt_user,
|
||||
opt_password, opt_db ? opt_db : "test",
|
||||
opt_port, opt_unix_socket, 0))
|
||||
{
|
||||
if (!opt_silent)
|
||||
printf("mysql_real_connect() failed: %s (%d)\n",
|
||||
mysql_error(conn), mysql_errno(conn));
|
||||
mysql_close(conn);
|
||||
DIE("");
|
||||
}
|
||||
|
||||
mysql_options(conn, MYSQL_SET_CHARSET_NAME, "ucs2");
|
||||
if (!mysql_change_user(conn, opt_user, opt_password, NULL))
|
||||
{
|
||||
if (!opt_silent)
|
||||
printf("mysql_change_user() succedded, error expected!");
|
||||
mysql_close(conn);
|
||||
DIE("");
|
||||
}
|
||||
|
||||
if (!opt_silent)
|
||||
printf("Got mysql_change_user() error (expected): %s (%d)\n",
|
||||
mysql_error(conn), mysql_errno(conn));
|
||||
mysql_close(conn);
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Bug #56976: Severe Denial Of Service in prepared statements
|
||||
*/
|
||||
static void test_bug56976()
|
||||
{
|
||||
MYSQL_STMT *stmt;
|
||||
MYSQL_BIND bind[1];
|
||||
int rc;
|
||||
const char* query = "SELECT LENGTH(?)";
|
||||
char *long_buffer;
|
||||
unsigned long i, packet_len = 256 * 1024L;
|
||||
unsigned long dos_len = 2 * 1024 * 1024L;
|
||||
|
||||
DBUG_ENTER("test_bug56976");
|
||||
myheader("test_bug56976");
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
check_stmt(stmt);
|
||||
|
||||
rc= mysql_stmt_prepare(stmt, query, strlen(query));
|
||||
check_execute(stmt, rc);
|
||||
|
||||
memset(bind, 0, sizeof(bind));
|
||||
bind[0].buffer_type = MYSQL_TYPE_TINY_BLOB;
|
||||
|
||||
rc= mysql_stmt_bind_param(stmt, bind);
|
||||
check_execute(stmt, rc);
|
||||
|
||||
long_buffer= (char*) my_malloc(packet_len, MYF(0));
|
||||
DIE_UNLESS(long_buffer);
|
||||
|
||||
memset(long_buffer, 'a', packet_len);
|
||||
|
||||
for (i= 0; i < dos_len / packet_len; i++)
|
||||
{
|
||||
rc= mysql_stmt_send_long_data(stmt, 0, long_buffer, packet_len);
|
||||
check_execute(stmt, rc);
|
||||
}
|
||||
|
||||
my_free(long_buffer, MYF(0));
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
|
||||
DIE_UNLESS(rc && mysql_stmt_errno(stmt) == ER_UNKNOWN_ERROR);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Read and parse arguments and MySQL options from my.cnf
|
||||
*/
|
||||
@ -18724,6 +18840,8 @@ static struct my_tests_st my_tests[]= {
|
||||
{ "test_bug42373", test_bug42373 },
|
||||
{ "test_bug54041", test_bug54041 },
|
||||
{ "test_bug47485", test_bug47485 },
|
||||
{ "test_bug58036", test_bug58036 },
|
||||
{ "test_bug56976", test_bug56976 },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user