Repository navigation
[6.1.9 Cherry-pick] Parser: Reject negative legacy (non-PLP) value lengths - #5185
Draft
github-actions[bot] wants to merge 2 commits into
Draft
github-actions[bot] wants to merge 2 commits into
github-actions[bot] wants to merge 2 commits into
Conversation
To resolve, run: git cherry-pick ec42969
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Reject malformed negative legacy (non-PLP) value lengths as corrupted TDS data instead of treating them as empty values. Valid values keep the existing exact-size allocation; zero-length and PLP values are unchanged. [6.1] Applied the TryGetDataLength check to the separate netcore and netfx TdsParser copies, and the non-PLP guard to TryReadStringWithEncoding (release/6.1 has no TryReadByteArrayWithContinue). Tests: retargeted the helper-level negative test to TryReadStringWithEncoding, dropped the exact-size helper test and the snapshot-continuation test (no continue mode on 6.1), removed compatibility-switch scopes, and enabled nullable context in the new test files. Kept 6.1's release-specific TESTGUIDE and added a section for these tests. (cherry picked from commit ec42969) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #5163 (ec42969) into
release/6.1.The merged #5163 rejects malformed negative legacy (non-PLP
image/text/ntext) value lengths as corrupted TDS data, instead of treating them as empty values and leaving bytes unconsumed. Valid values keep their existing exact-size allocation.Conflict resolution
release/6.1has separate netcore and netfxTdsParsercopies and doesn't haveTdsParserStateObject.TryReadByteArrayWithContinue.TryGetDataLength: applied theintLength < 0check to bothnetcore/src/.../Parser/TdsParser.csandnetfx/src/.../Parser/TdsParser.cs. Kept 6.1's sharedTdsParser.csunchanged.TdsParserStateObject.cs: kept 6.1's code. Instead of addingTryReadByteArrayWithContinue, added the same!isPlp && length < 0guard to 6.1's non-PLPTryReadStringWithEncodingpath.TESTGUIDE.md: 6.1's guide is release-specific, so it was kept and a short section was added for these tests.Test adaptation
TdsParserStateObjectTests: the negative-length helper test now targetsTryReadStringWithEncoding. The exact-size helper test was dropped, because 6.1's allocation path wasn't changed.SqlDataReaderTests:UseCompatibilityProcessSni/UseCompatibilityAsyncBehaviourscopes, which aren't on 6.1, whose async behavior is the legacy mode;ReadAsync_FragmentedLegacyLob_ResumesValue, which needs snapshot "continue" support 6.1 doesn't have;#nullable enableto the new test files, because 6.1's unit tests have no nullable context.Testing
dotnet build build.proj -t:BuildNetCore— passed.dotnet build src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj -p:OSGroup=Windows_NT— passed. This compiles netfx; netfx tests were not run on Linux.dotnet test src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj -p:TestTargetOS=Unixnetcoreapp --filter "(FullyQualifiedName~UnitTests.SqlDataReaderTests|FullyQualifiedName~UnitTests.TdsParserStateObjectTests)&category!=failing&category!=flaky"— passed, 48/48 on net8.0 and net9.0. Without the product change, the 3 negative-length tests failed (sync, async and helper).category!=failing&category!=flaky&category!=interactive) — 695 passed, 1 failed. The failure,ConnectionFailoverTests.TransientFault_IgnoreServerProvidedFailoverPartner_ShouldConnectToUserProvidedPartner, also fails on unmodifiedrelease/6.1in the same environment.