Bug #45355 ER_TABLEACCESS_DENIED_ERROR error message truncated
Submitted: 5 Jun 2009 17:12 Modified: 4 Aug 2010 22:51
Reporter: Marc Alff Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:6.0, 4.1, 5.0, 5.1 OS:Any
Assigned to: Marc Alff CPU Architecture:Any
Triage: Triaged: D4 (Minor)

[5 Jun 2009 17:12] Marc Alff
Description:
The error message ER_TABLEACCESS_DENIED_ERROR contains:

eng "%-.16s command denied to user ..."

This truncates the command part to 16 characters, which is too short.

See in sql_acl.cc that:

    char command[128];
    get_privilege_desc(command, sizeof(command), want_access, FALSE);
    my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
             command,
             sctx->priv_user,
             sctx->host_or_ip,
             table ? table->get_table_name() : "unknown");

the message can be called with the result of get_privilege_desc(),
which can be much bigger, since it's a comma/pipe separated list of
privilege names.

See command_array:

static const char *command_array[]=
{
  "SELECT", "INSERT", "UPDATE", "DELETE", "CREATE", "DROP", "RELOAD",
  "SHUTDOWN", "PROCESS","FILE", "GRANT", "REFERENCES", "INDEX",
  "ALTER", "SHOW DATABASES", "SUPER", "CREATE TEMPORARY TABLES",
  "LOCK TABLES", "EXECUTE", "REPLICATION SLAVE", "REPLICATION CLIENT",
  "CREATE VIEW", "SHOW VIEW", "CREATE ROUTINE", "ALTER ROUTINE",
  "CREATE USER", "EVENT", "TRIGGER", "CREATE TABLESPACE"
};

How to repeat:
Read the code.

Reproduced with new tests in mysql-6.0-perfschema:

lock table performance_schema.EVENTS_WAITS_CURRENT write;
ERROR 42000: SELECT,LOCK TABL command denied to user 'pfs_user_1'@'localhost' for table 'EVENTS_WAITS_CURRENT'

It should read "SELECT,LOCK TABLES command denied ..."
[5 Jun 2009 19:41] Miguel Solorzano
Thank you for the bug report.
[18 Mar 2010 15:35] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/103712
[13 Apr 2010 14:57] Marc Alff
Queued in:
- mysql-next-mt-bugfixing
- mysql-6.0-codebase-bugfixing
[27 Apr 2010 9:46] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100427094135-5s49ecp3ckson6e2) (version source revid:alik@sun.com-20100427093843-uekr85qkd7orx12t) (merge vers: 6.0.14-alpha) (pib:16)
[27 Apr 2010 9:52] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100427094036-38frbg3famdlvjup) (version source revid:alik@sun.com-20100427093825-92wc8b22d4yg34ju) (pib:16)
[12 May 2010 1:47] Paul Dubois
Noted in 6.0.14 changelog.

In the ER_TABLEACCESS_DENIED_ERROR error message, the command name
parameter could be truncated.
[4 Aug 2010 8:07] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:alik@sun.com-20100427095914-pzlxbqjjtnngxmf0) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 8:23] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:alik@sun.com-20100427095914-pzlxbqjjtnngxmf0) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 22:51] Paul Dubois
Noted in 5.6.0 changelog.