Bug #117603 Connectionstrings crafted with `dns-srv=true` and (at least) POOLING set break MySqlConnectionStringBuilder
Submitted: 28 Feb 14:38 Modified: 28 Feb 16:19
Reporter: Davyd McColl Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:9.2.0 OS:Windows
Assigned to: CPU Architecture:x86

[28 Feb 14:38] Davyd McColl
Description:
I found that creating MySqlConnectionStringBuilder instances with randomized parameters and calling .ToString() to render them would periodically fail with a NullReferenceException. Digging a little deeper, I've reproduced the issue, with a hint as to where the problem lies within the MySql.Data code here: https://github.com/fluffynuts/MySqlConnectionStringBuilderNullReferenceException

How to repeat:
https://github.com/fluffynuts/MySqlConnectionStringBuilderNullReferenceException

Suggested fix:
Within AnalyzeConnectionString, when setting the flag that `dns-srv=true` has been set, there's an attempt to look up the connection string option from `MySqlConnectionStringBuilder.Options.Options`, via `FirstOrDefault()` which can yield a null value, and that value is simply dereferenced a line later if the prior flag was set to true, without any validation that it isn't null.
[28 Feb 16:19] MySQL Verification Team
Hello Davyd McColl,

Thank you for the report and test case.

regards,
Umesh