| Bug #76913 | suspicious code in str_to_datetime | ||
|---|---|---|---|
| Submitted: | 2 May 2015 11:13 | Modified: | 8 Jun 2015 10:34 |
| Reporter: | Shane Bester (Platinum Quality Contributor) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Data Types | Severity: | S3 (Non-critical) |
| Version: | 5.5, 5.6, 5.7, 8.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[2 May 2015 11:53]
MySQL Verification Team
in 5.0, 5.1 it looks okay. since 5.5.0, this bug exists.
[8 Jun 2015 10:34]
MySQL Verification Team
verifying as the code is obviously wrong but i cannot get a sql testcase to hit this line ;)

Description: In the function str_to_datetime in .\sql-common\my_time.c we have this fragment of code that looks strange: if (str+2 <= end && (str[1] == 'M' || str[1] == 'm')) { if (str[0] == 'p' || str[0] == 'P') add_hours= 12; -----> else if (str[0] != 'a' || str[0] != 'A') <------------- continue; /* Not AM/PM */ str+= 2; /* Skip AM/PM */ /* Skip space after AM/PM */ How to repeat: Read the code. Sorry, I can't get a testcase to do coverage of this part code... Suggested fix: - else if (str[0] != 'a' || str[0] != 'A') + else if (str[0] != 'a' && str[0] != 'A')