[MDEV-4664] mysql_upgrade crashes if root's password contains an apostrophe/single quotation mark Created: 2013-06-15 Updated: 2016-02-06 Resolved: 2016-02-06 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Scripts & Clients |
| Affects Version/s: | 10.0.3, 5.5.31, 5.1.67, 5.2.14, 5.3.12 |
| Fix Version/s: | 5.5.48, 10.0.24, 10.1.12 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Joe MacMahon | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | mysql_upgrade, upstream | ||
| Environment: |
Using Arch Linux x86_64 |
||
| Issue Links: |
|
||||||||
| Description |
|
Expected behaviour: mysql_upgrade completes successfully when using a password containing a single quotation mark ('). Actual behaviour mysql_upgrade crashes with the following:
|
| Comments |
| Comment by Elena Stepanova [ 2013-06-15 ] | |||||||||||||||||||||||||||||||||||||||||||
|
Also reproducible on all of MySQL 5.1-5.7 | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Jean Weisbuch [ 2015-01-06 ] | |||||||||||||||||||||||||||||||||||||||||||
|
Here is a patch for this bug :
Before patching, if the provided password has a quote (maria'db on the example), the command executed using popen() on mysql_upgrade.c on the function run_command() looks like this :
The issue is that on a POSIX shell, you cannot escape anything on simple quoted string not even a simple quote, to do so you must close the simple quote, open a double quotes, put your simple quote on it then close the double quotes, for example :
After applying the patch, the resulting executed command looks like :
I only tested the patch on Linux but to mimic the Windows behavior i inverted the quote_str and quote_len values from the Windows and Linux values and it worked fine too with double quotes instead of simple ones but i wasnt on a Windows OS so i am not 100% sure it wouldnt require a real test on it. ps: another small "bug" is that even if i didnt specify the user on the command line, it is passed twice on the mysql client. |