Skip to content

Commit

Permalink
Fix segfault in audit plugin codepath
Browse files Browse the repository at this point in the history
Summary:
The THD pointer is not always available when the audit plugin is called. The causes a problem when we try to access thd->query_id.

 Fix by doing a null check first. If the THD is null, then we copy what is done for thread_id, we just set query_id to 0.

Squash with: 1def6b7 Expose more information to audit plugin

Test Plan: mtr

Reviewers: jkedgar, hermanlee4, drilibo

Reviewed By: drilibo

Subscribers: webscalesql-eng

Differential Revision: https://reviews.facebook.net/D58287
  • Loading branch information
lth committed May 16, 2016
1 parent e6680d0 commit ba03c70
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sql/sql_audit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static void general_class_handler(THD *thd, uint event_subtype, va_list ap)
event.database_length= va_arg(ap, unsigned int);
event.query_attributes= va_arg(ap, const char*);
event.query_attributes_length= va_arg(ap, unsigned int);
event.query_id= (unsigned long long) thd->query_id;
event.query_id= thd ? (unsigned long long) thd->query_id : 0LL;
event_class_dispatch(thd, MYSQL_AUDIT_GENERAL_CLASS, &event);
}

Expand Down

0 comments on commit ba03c70

Please sign in to comment.