Skip to content

Fix offsetInBuffer validation in SqlBytes.Read - #138264

Open
aaronfranke wants to merge 1 commit into
dotnet:mainfrom
aaronfranke:fix-1.1-sql-bytes-read-buffer
Open

aaronfranke wants to merge 1 commit into
dotnet:mainfrom
aaronfranke:fix-1.1-sql-bytes-read-buffer

Conversation

@aaronfranke

Copy link
Copy Markdown
Contributor

offsetInBuffer is compared against the SqlBytes length, but it should be the buffer length.

This fix matches existing code in SqlBytes.Write and SqlChars.Read.

Minimal reproduction project: sqlbytes-read-offset.zip


AI usage disclaimer: I encountered these .NET runtime bugs when using an AI to work on an unrelated project. I had it fix the bugs as it went, and now I am submitting fixes to each after manually reviewing the changes, and fixing them as needed. Most of these lines of code are AI-generated, including the tests and the MRP. The PR description and commit message are entirely human-written, as is always the case with every PR I open.

`offsetInBuffer` is compared against the `SqlBytes` length,
but it should be the buffer length.

This fix matches existing code in `SqlBytes.Write` and `SqlChars.Read`.
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 25, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @David-Engel, @cheenamalhotra
See info in area-owners.md if you want to be subscribed.

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

area-System.Data.SqlClient community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant