Skip to content

[7.0.5 Cherry-pick] Parser: Reject negative legacy (non-PLP) value lengths - #5188

Draft
github-actions[bot] wants to merge 2 commits into
release/7.0from
dev/automation/pr-5163-to-7.0.5
Draft

github-actions[bot] wants to merge 2 commits into
release/7.0from
dev/automation/pr-5163-to-7.0.5

Conversation

@github-actions

@github-actions github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Cherry-pick of #5163 (ec42969) into release/7.0.

Conflict resolution

The product changes in TdsParser.cs and TdsParserStateObject.cs, and all new tests, applied cleanly. The only conflict was TESTGUIDE.md, which doesn't exist on release/7.0; that doc change was dropped.

Testing

  • dotnet build build.proj -t:BuildNetCore — passed.
  • dotnet build src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj -f net462 -p:TargetOs=Windows_NT — passed. This compiles net462; net462 tests were not run on Linux.
  • dotnet test src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj --filter "(FullyQualifiedName~UnitTests.SqlDataReaderTests|FullyQualifiedName~UnitTests.TdsParserStateObjectTests)&category!=failing&category!=flaky" — passed, 54/54 on net8.0, net9.0 and net10.0. Without the product change, the 3 negative-length tests failed (sync, async and helper).

To resolve, run:  git cherry-pick ec42969
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

* Parser: Grow non-PLP value buffers as payload arrives

Non-sequential reads of non-PLP values (legacy image, text and ntext) previously allocated the full declared length before the value arrived. The buffer now grows with received payload, bounded by the declared length, and encoded string reads share the same path. Large and multi-packet values, async continuation and sequential streaming are unchanged; no new size limit is introduced.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix snapshot continuation lengths and regression coverage for PR #5163

Preserve declared non-PLP value lengths independently of growing buffers and use them in both parser continuation paths.

Exercise retained-buffer continuation with restoring compatibility switches and two packet gates, and document the coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Reject negative non-PLP value lengths for PR #5163

Reject malformed negative legacy value lengths before snapshot continuation and at the token-length boundary while preserving valid zero-length and PLP behavior.

Add helper-level plus synchronous and asynchronous simulated-server regressions, and document the coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Document incremental value materialization intent

Explain why non-PLP buffers grow from received payload, how continuation storage retains declared length, and why malformed lengths and replay use the guarded paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Preserve legacy non-PLP materialization performance

Keep the established exact-size allocation path for valid legacy values while rejecting unsigned 32-bit lengths that exceed the signed allocation ceiling.

Update parser tests and test guidance to cover exact-size allocation and malformed-length rejection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit ec42969)
@paulmedynski paulmedynski changed the title [7.0.5 Cherry-pick - CONFLICTS] Parser: Grow non-PLP value buffers as payload arrives [7.0.5 Cherry-pick] Parser: Grow non-PLP value buffers as payload arrives Dec 4, 2026
@paulmedynski paulmedynski changed the title [7.0.5 Cherry-pick] Parser: Grow non-PLP value buffers as payload arrives [7.0.5 Cherry-pick] Parser: Reject negative legacy (non-PLP) value lengths Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

1 participant