Skip to content

Commit

Permalink
Fix crash in audit plugin path
Browse files Browse the repository at this point in the history
Summary:
This commit 3b47dae introduced a crash in the audit plugin code path during server initialization, because it was calling strlen on a nullptr. Fix by doing a check first.

Squash with: D4562120

Reviewed By: abal147

Differential Revision: D4580019

fbshipit-source-id: 590a66d
  • Loading branch information
lth authored and facebook-github-bot committed Feb 17, 2017
1 parent ae2e18d commit 87e0683
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sql/sql_audit.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void mysql_audit_general_log(THD *thd, const char *cmd, uint cmdlen,
if (thd)
{
user= thd->security_ctx->user;
userlen= strlen(thd->security_ctx->user);
userlen= thd->security_ctx->user ? strlen(thd->security_ctx->user) : 0;
if (!query_len)
{
/* no query specified, fetch from THD */
Expand Down Expand Up @@ -186,7 +186,7 @@ void mysql_audit_general(THD *thd, uint event_subtype,
else
query= thd->query_string;
user= thd->security_ctx->user;
userlen= strlen(thd->security_ctx->user);
userlen= thd->security_ctx->user ? strlen(thd->security_ctx->user) : 0;
affectrows= thd->get_row_count_func();
resultrows= thd->get_sent_row_count();
ip.str= (char *) thd->security_ctx->get_ip()->ptr();
Expand Down

0 comments on commit 87e0683

Please sign in to comment.