Bug #11330 4.1.12 crashes when row with empty host is added to mysql.tables_priv
Submitted: 14 Jun 2005 21:36 Modified: 7 Jul 2005 13:19
Reporter: Kolbe Kegel Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.12 OS:Linux (Linux)
Assigned to: Jim Winstead CPU Architecture:Any

[14 Jun 2005 21:36] Kolbe Kegel
Description:
Manually inserting a row with host='' into mysql.tables_priv and doing FLUSH PRIVILEGES causes the server to crash.

How to repeat:
Starting with clean 4.1.12 install...

* Run ./scripts/mysql_install_db
* Start server with ./bin/mysqld --data="$PWD"/data
* Execute INSERT INTO `tables_priv` VALUES ('','bugtest','test_table','test_grantor','',CURRENT_TIMESTAMP,'Select','Select');
* Execute FLUSH PRIVILEGES

The server will crash, and will be unable to restart.

This behavior does not occur in 5.0.6.

Including gdb output.

Suggested fix:
Ignore malformed/nonsensical entries in grant tables, or issue an error when they're created or encountered.
[14 Jun 2005 21:36] Kolbe Kegel
Gdb backtrace

Attachment: gdb.out (application/octet-stream, text), 7.32 KiB.

[15 Jun 2005 16:16] MySQL Verification Team
Hello,

I had originaly found this bug on Monday and had been working with Kolbe throught a support ticket to resolve this.  I'm not sure what the best way to handle or prevent this sort of case in the future would be, but I would like to throw some ideas out for comment.

Perhaps making the grant tables read only by default unless changes are issued throught "GRANT" or "REVOKE" is a good way of preventing erroneous records in the first place.  If someone really wants to directly update the grants tables there should be an option/variable  that would permit that, like... SET @@session.edit-grants='True'.  

This sort of change would require that the variable be set in the mysqldump output so that
you can import the tables, or mysqldump would need to export 'GRANT' commands (like 'SHOW GRANTS' does) rather than the rows directly.  That could also make the export a bit more portable between older and newer versions of mysql where there are differences in the grants tables.  But could prevent a SQL dump from being able to complete when the server was started with "skip-grant-tables".

Thank You,

Matthew Montgomery
Rackspace Managed Hosting
[20 Jun 2005 17:21] 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/internals/26209
[5 Jul 2005 23:50] Jim Winstead
Fixed in 4.1.13 and 5.0.9.
[7 Jul 2005 13:19] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented in 4.1.13 and 5.0.9 change histories; closed.