Skip to content

Commit 887f46a

Browse files
committed
fix mysqltest crash report output
* read_command_buf is a pointer now, sizeof() no longer reflects its length, read_command_buflen is. * my_safe_print_str() prints multiple screens of '\0' bytes after the query end and up to read_command_buflen. Use fprintf() instead. * when setting connection->name to "-closed_connection-" update connection->name_len to match.
1 parent 4352c77 commit 887f46a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

client/mysqltest.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ static my_bool non_blocking_api_enabled= 0;
9090

9191
#define QUERY_PRINT_ORIGINAL_FLAG 4
9292

93+
#define CLOSED_CONNECTION "-closed_connection-"
94+
9395
#ifndef HAVE_SETENV
9496
static int setenv(const char *name, const char *value, int overwrite);
9597
#endif
@@ -5569,11 +5571,12 @@ void do_close_connection(struct st_command *command)
55695571
my_free(con->name);
55705572

55715573
/*
5572-
When the connection is closed set name to "-closed_connection-"
5574+
When the connection is closed set name to CLOSED_CONNECTION
55735575
to make it possible to reuse the connection name.
55745576
*/
5575-
if (!(con->name = my_strdup("-closed_connection-", MYF(MY_WME))))
5577+
if (!(con->name = my_strdup(CLOSED_CONNECTION, MYF(MY_WME))))
55765578
die("Out of memory");
5579+
con->name_len= sizeof(CLOSED_CONNECTION)-1;
55775580

55785581
if (con == cur_con)
55795582
{
@@ -5957,7 +5960,7 @@ void do_connect(struct st_command *command)
59575960
con_slot= next_con;
59585961
else
59595962
{
5960-
if (!(con_slot= find_connection_by_name("-closed_connection-")))
5963+
if (!(con_slot= find_connection_by_name(CLOSED_CONNECTION)))
59615964
die("Connection limit exhausted, you can have max %d connections",
59625965
opt_max_connections);
59635966
my_free(con_slot->name);
@@ -8980,7 +8983,7 @@ static void dump_backtrace(void)
89808983
struct st_connection *conn= cur_con;
89818984

89828985
fprintf(stderr, "read_command_buf (%p): ", read_command_buf);
8983-
my_safe_print_str(read_command_buf, sizeof(read_command_buf));
8986+
fprintf(stderr, "%.*s\n", (int)read_command_buflen, read_command_buf);
89848987
fputc('\n', stderr);
89858988

89868989
if (conn)

0 commit comments

Comments
 (0)