Skip to content

Conversation

Midhunnnk
Copy link
Contributor

Fixes #3110
this PR fixes a crash in ADP.IsEndpoint(...) caused by an unsafe call to LastIndexOf('\\', length - 1, length - 1) when the Data Source in the connection string starts with a comma (e.g. "Data Source=,").

When length == 0, the method would previously throw an ArgumentOutOfRangeException.

---Fix
Added a defensive check to ensure length > 0 before calling LastIndexOf, which prevents invalid index access.

--- Tests

  • Added a new unit test: ConnectionString_WithOnlyComma_ShouldNotThrow
  • The test confirms that the exception is no longer thrown
  • Verified the test fails without the fix and passes with it

This is my first open-source contribution — excited to be part of the project! Let me know if you'd like any changes.

@Midhunnnk
Copy link
Contributor Author

@dotnet-policy-service agree

@paulmedynski paulmedynski self-assigned this Apr 1, 2025
Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fisrt open-source contribution! Little bugs like these can be very frustrating for users, so we appreciate you taking the time to fix one :)

@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Midhunnnk
Copy link
Contributor Author

@paulmedynski Thank you for the feedback, it helps a lot 😄 I've updated the test name and replaced Record.Exception with Assert.Throws() as suggested. Let me know if you'd like anything else adjusted — happy to improve further!

@cheenamalhotra
Copy link
Member

/azp run

@cheenamalhotra cheenamalhotra added this to the 6.1-preview1 milestone Apr 1, 2025
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look great - thanks!

@mdaigle mdaigle self-assigned this Apr 2, 2025
@paulmedynski paulmedynski merged commit 9d71471 into dotnet:main Apr 2, 2025
123 checks passed
Copy link

codecov bot commented Apr 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (1247ca4) to head (ccbf510).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #3250       +/-   ##
==========================================
- Coverage   72.69%       0   -72.70%     
==========================================
  Files         303       0      -303     
  Lines       59718       0    -59718     
==========================================
- Hits        43414       0    -43414     
+ Misses      16304       0    -16304     
Flag Coverage Δ
addons ?
netcore ?
netfx ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This was referenced Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ArgumentOutOfRange when datasource starts with comma
5 participants