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:
None 
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
Description:
chk_data_link() in storage/myisam/mi_check.c can potentially divide by zero while printing out information at the end, when it divides by 'records' and records happens to be zero.  (There's a check for records being zero in one place where the division happens, but there isn't such a check in two other similar places.)
I will shortly attach an obvious patch to fix this problem (the submission page does not appear to have an attachment option).

How to repeat:
See above.
[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] Shane Bester
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).

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.