Bug #117603 Connectionstrings crafted with `dns-srv=true` and (at least) POOLING set break MySqlConnectionStringBuilder

Submitted: 28 Feb 2025 14:38 Modified: 4 Nov 2025 20:00
Reporter: Davyd McColl Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:9.2.0 OS:Windows
Assigned to: CPU Architecture:x86

[28 Feb 2025 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 2025 16:19] MySQL Verification Team
Hello Davyd McColl,

Thank you for the report and test case.

regards,
Umesh
[4 Nov 2025 20:00] Edward Gilmore
Posted by developer:
 
 Added the following note to the MySQL Connector/NET 9.5.0 release notes:

 Setting dns-srv=True or POOLING=true could cause MySqlConnectionStringBuilder to fail with a
 NullReferenceException

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

Page generated in 0.051 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.