summaryrefslogtreecommitdiff
path: root/sql/sql_audit.h
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2014-02-28 00:23:20 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2014-02-28 00:23:20 +0400
commit3f3a84f46e564e482c00023d903cc5c03914c99a (patch)
tree39a0e0771129e6ff69af4c7107f7d22ba7ccc3b5 /sql/sql_audit.h
parent525c00c682bc536757b336ff5f3aee7725a5a852 (diff)
downloadmariadb-git-3f3a84f46e564e482c00023d903cc5c03914c99a.tar.gz
MDEV-5436 mysqld crash signal 11 in mysql_audit_general.
That error 'Can't open the pid file' leads to mysqld crash signal 11 in mysql_audit_general() called with the 'thd' parameter set to NULL. That wasn't checked when the thd->db and thd->db_length were accessed. Fixed by checking for the NULL thd.
Diffstat (limited to 'sql/sql_audit.h')
-rw-r--r--sql/sql_audit.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/sql_audit.h b/sql/sql_audit.h
index 9acd4abbdca..3f3f97a2730 100644
--- a/sql/sql_audit.h
+++ b/sql/sql_audit.h
@@ -90,11 +90,13 @@ void mysql_audit_general_log(THD *thd, time_t time,
{
CHARSET_INFO *clientcs= thd ? thd->variables.character_set_client
: global_system_variables.character_set_client;
+ const char *db= thd ? thd->db : "";
+ size_t db_length= thd ? thd->db_length : 0;
mysql_audit_notify(thd, MYSQL_AUDIT_GENERAL_CLASS, MYSQL_AUDIT_GENERAL_LOG,
0, time, user, userlen, cmd, cmdlen,
query, querylen, clientcs, (ha_rows) 0,
- thd->db, thd->db_length);
+ db, db_length);
}
}
@@ -123,6 +125,8 @@ void mysql_audit_general(THD *thd, uint event_subtype,
char user_buff[MAX_USER_HOST_SIZE];
CSET_STRING query;
ha_rows rows;
+ const char *db;
+ size_t db_length;
if (thd)
{
@@ -130,18 +134,22 @@ void mysql_audit_general(THD *thd, uint event_subtype,
user= user_buff;
userlen= make_user_name(thd, user_buff);
rows= thd->warning_info->current_row_for_warning();
+ db= thd->db;
+ db_length= thd->db_length;
}
else
{
user= 0;
userlen= 0;
rows= 0;
+ db= "";
+ db_length= 0;
}
mysql_audit_notify(thd, MYSQL_AUDIT_GENERAL_CLASS, event_subtype,
error_code, time, user, userlen, msg, msglen,
query.str(), query.length(), query.charset(), rows,
- thd->db, thd->db_length);
+ db, db_length);
}
}