Bug #68113 | Avoid division by zero in MyISAM's chk_data_link | ||
---|---|---|---|
Submitted: | 17 Jan 2013 22:27 | Modified: | 18 Jan 2013 5:05 |
Reporter: | Nickolai Zeldovich | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: MyISAM storage engine | Severity: | S3 (Non-critical) |
Version: | 5.5.28 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[17 Jan 2013 22:27]
Nickolai Zeldovich
[17 Jan 2013 22:28]
Nickolai Zeldovich
A proposed patch to avoid division by zero
Attachment: mp.patch (text/x-patch), 1.05 KiB.
[18 Jan 2013 3:54]
MySQL Verification Team
Thanks for the patch. Did you actually meet any scenario where you hit a division by zero on a table ? If so, is it possible to upload the .frm .MYI .MYD for that table ?
[18 Jan 2013 5:05]
Nickolai Zeldovich
Sorry, I should have clarified: my report was based on code inspection rather than a concrete file that triggers a bug. Indeed, I believe the current code makes it impossible to trigger the division by zero: if 'used' is non-zero, then either 'records' is also non-zero, or 'param->error_printed' is set, and since the print statements in question only execute if 'param->error_printed' is not set and 'used' is non-zero, then 'records' must be non-zero. However, in that case, the check for 'records' being zero, in '(!records ? 100 : ...)', is superfluous, since 'records' can never be zero, making the current code inconsistent: either the developer should believe 'records' can be zero (and then check it in all places), or it cannot (and then not bother checking anywhere).