Bug #73523 executing innochecksum on an unreadable file produces random error message
Submitted: 10 Aug 2014 17:03 Modified: 11 Aug 2014 7:26
Reporter: David Bennett Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.6, 5.6.19 OS:Windows
Assigned to: CPU Architecture:Any
Tags: mysql extra innochecksum utility

[10 Aug 2014 17:03] David Bennett
Description:
Running the innochecksum.exe utility on the Windows platform on a file that is not readable causes random data to be output.

How to repeat:
icacls ibdata1 /reset
icacls ibdata1 /inheritance:r /grant:r Everyone:W
innochecksum.exe -v ibdata1
InnoDB offline file checksum utility.

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
verbose                           TRUE
debug                             FALSE
count                             FALSE
start-page                        0
end-page                          0
page                              0
Filename::Access is denied. {random data appears here}

Suggested fix:
when the function open_file() in the source file extra\innochecksum.cc encounters a windows INVALID_HANDLE_VALUE error condition it reports the error to stderr and returns null.

The fprintf call is expecting two parameters (name, error_msg) and only the error_msg is specified.
[10 Aug 2014 17:14] David Bennett
extra_innochecksum.cc_bug_73523.patch

Attachment: extra_innochecksum.cc_bug_73523.patch (text/x-patch), 520 bytes.

[11 Aug 2014 7:26] MySQL Verification Team
Hello David,

Thank you for the bug report and contribution.
Verified as described.

Thanks,
Umesh
[11 Aug 2014 7:30] MySQL Verification Team
innochecksum.exe -v ibdata1
InnoDB offline file checksum utility.

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
verbose                           TRUE
debug                             FALSE
count                             FALSE
start-page                        0
end-page                          0
page                              0

Faulting application name: innochecksum.exe, version: 5.6.19.0, time stamp: 0x5368cc26
Faulting module name: innochecksum.exe, version: 5.6.19.0, time stamp: 0x5368cc26
Exception code: 0xc0000005
Fault offset: 0x00000000000d3652
Faulting process id: 0x2c4c
Faulting application start time: 0x01cfb52c9360b56c
Faulting application path: D:\ushastry\mysql-advanced-5.6.19-winx64\bin\innochecksum.exe
Faulting module path: D:\ushastry\mysql-advanced-5.6.19-winx64\bin\innochecksum.exe
Report Id: d13d1338-211f-11e4-8caa-bc305bc8d894
[11 Aug 2014 7:36] MySQL Verification Team
fprintf expecting two char*  parameters but only 1 given

mysql-5.6/extra/innochecksum.cc:

157  			OPEN_EXISTING, NULL, NULL);
158  
159: 	if (hFile == INVALID_HANDLE_VALUE) {
160  		/* print the error message. */
161  		fprintf(stderr, "Filename::%s %s\n",	  
162			win32_error_message(GetLastError()));
163			return (NULL);
164
165
[22 Oct 2014 8:24] Daniƫl van Eeden
Is this also affecting innochecksum from MySQL 5.7?
[21 Aug 2015 15:20] MySQL Verification Team
Bug still exists on current mysql-trunk.
Only 3 of 4 expected parameters are given to fprintf in function open_file of innochecksum.cc, line 264