Bug #87316 Setting CommandTimeout=-1 doesn't throw ArgumentException
Submitted: 4 Aug 2017 6:02 Modified: 4 Aug 2017 6:33
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Verified Impact on me:
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.9.9 OS:Microsoft Windows (10.0.15063 x64)
Assigned to: CPU Architecture:Any

[4 Aug 2017 6:02] Bradley Grainger
The argument validation logic in the MySqlCommand.CommandTimeout setter is incorrect, and allows CommandTimeout to be set to a negative value. (Setting it to a valid value subsequently will throw an ArgumentException.)

How to repeat:
var command = new MySqlCommand();
Console.WriteLine("setting CommandTimeout to -1");
command.CommandTimeout = -1; // doesn't throw
Console.WriteLine("setting CommandTimeout to 100");
command.CommandTimeout = 100; // throws "ArgumentException: Command timeout must not be negative"

Suggested fix:
Change https://github.com/mysql/mysql-connector-net/blob/5864e6b21a8b32f5154b53d1610278abb3cb1cee... from:

if (commandTimeout < 0)


if (value < 0)
[4 Aug 2017 6:33] Chiranjeevi Battula
Hello Bradley Grainger,

Thank you for the bug report and test case.
Verified this behavior on Visual Studio 2013 (C#.Net) and Connector/NET 6.9.9 version.

[4 Aug 2017 6:34] Chiranjeevi Battula

Attachment: 87316.JPG (image/jpeg, text), 202.19 KiB.