Repository navigation
Fix DNS_ADDR_ARRAY.MaxCount: use byte size instead of element count - #130608
Merged
Merged
Conversation
DNS_ADDR_ARRAY.MaxCount indicates the size in bytes of the structure, not the count of elements. Set MaxCount to totalSize (the total byte size of the allocated buffer) instead of count (the number of DNS server entries). Fixes #130544 Co-authored-by: rzikm <[email protected]>
Copilot
AI
changed the title
[WIP] Fix invalid DNS_ADDR_ARRAY handling
Fix DNS_ADDR_ARRAY.MaxCount: use byte size instead of element count
Jul 13, 2026
rzikm
approved these changes
Jul 13, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR corrects the Windows DNS interop initialization for DNS_ADDR_ARRAY by setting MaxCount to the total allocated byte size of the structure (header + trailing DNS_ADDR entries), aligning with the Win32 contract for DnsQueryEx custom server lists.
Changes:
- Fix
BuildAddrArrayto assignDNS_ADDR_ARRAY.MaxCount = totalSize(bytes) instead ofcount(elements).
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
MihaZupan
approved these changes
Jul 13, 2026
rzikm
enabled auto-merge (squash)
July 13, 2026 11:43
Member
|
/ba-g System.Text.Json.Tests.WorkItemExecution crash is unrelated |
eiriktsarpalis
pushed a commit
that referenced
this pull request
Jul 15, 2026
…130608) `DNS_ADDR_ARRAY.MaxCount` [documents](https://learn.microsoft.com/en-us/windows/win32/api/windnsdef/ns-windnsdef-dns_addr_array) as the size in bytes of the structure, not the number of entries. `BuildAddrArray` was incorrectly assigning the element count. **Change:** Set `MaxCount` to `totalSize` (total allocated byte size of the header + all trailing `DNS_ADDR` entries) instead of `count`. ```csharp // Before arr.MaxCount = (uint)count; // After arr.MaxCount = (uint)totalSize; ``` --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: rzikm <[email protected]>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
DNS_ADDR_ARRAY.MaxCountdocuments as the size in bytes of the structure, not the number of entries.BuildAddrArraywas incorrectly assigning the element count.Change: Set
MaxCounttototalSize(total allocated byte size of the header + all trailingDNS_ADDRentries) instead ofcount.