Skip to content

Commit a732d5e

Browse files
committed
Bug#23540008 SAFE GUARD FOR CHARSET_INFO RETURNED FROM GET_CHARSET
When executing a SELECT from tables: - performance_schema.events_statements_current - performance_schema.events_statements_history - performance_schema.events_statements_history_long the code reads data that can be concurrently written to. This race condition is expected (performance schema data buffers are lock less), but the code is not robust enought. In particular, the character set for the sql query text may be invalid. Before this fix, this condition could cause a crash. With this fix, reading an invalid character set will truncate the SQL TEXT column.
1 parent b079401 commit a732d5e

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

storage/perfschema/table_events_statements.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -340,11 +340,17 @@ void table_events_statements_common::make_row_part_1(PFS_events_statements *stat
340340
CHARSET_INFO *cs= get_charset(statement->m_sqltext_cs_number, MYF(0));
341341
size_t valid_length= statement->m_sqltext_length;
342342

343-
if (cs->mbmaxlen > 1)
343+
if (cs != NULL)
344344
{
345-
int well_formed_error;
346-
valid_length= cs->cset->well_formed_len(cs, statement->m_sqltext, statement->m_sqltext + valid_length,
347-
valid_length, &well_formed_error);
345+
if (cs->mbmaxlen > 1)
346+
{
347+
int well_formed_error;
348+
valid_length= cs->cset->well_formed_len(cs,
349+
statement->m_sqltext,
350+
statement->m_sqltext + valid_length,
351+
valid_length,
352+
&well_formed_error);
353+
}
348354
}
349355

350356
m_row.m_sqltext.set_charset(cs);

0 commit comments

Comments
 (0)