Skip to content

Fix DNS_ADDR_ARRAY.MaxCount: use byte size instead of element count - #130608

Merged
rzikm merged 2 commits into
mainfrom
copilot/fix-invalid-dns-addr-array-handling
Jul 13, 2026
Merged

rzikm merged 2 commits into
mainfrom
copilot/fix-invalid-dns-addr-array-handling

Conversation

Copilot AI commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

DNS_ADDR_ARRAY.MaxCount documents 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.

// Before
arr.MaxCount = (uint)count;

// After
arr.MaxCount = (uint)totalSize;

Copilot AI requested review from Copilot and removed request for Copilot July 13, 2026 09:01
Copilot AI linked an issue Jul 13, 2026 that may be closed by this pull request
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 requested review from Copilot and removed request for Copilot July 13, 2026 09:08
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
Copilot finished work on behalf of rzikm July 13, 2026 09:09
Copilot AI requested a review from rzikm July 13, 2026 09:09
@rzikm
rzikm marked this pull request as ready for review July 13, 2026 09:38
@rzikm
rzikm requested review from a team and Copilot July 13, 2026 09:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 BuildAddrArray to assign DNS_ADDR_ARRAY.MaxCount = totalSize (bytes) instead of count (elements).

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@rzikm
rzikm enabled auto-merge (squash) July 13, 2026 11:43
@rzikm

rzikm commented Jul 13, 2026

Copy link
Copy Markdown
Member

/ba-g System.Text.Json.Tests.WorkItemExecution crash is unrelated

@rzikm
rzikm merged commit e9157ea into main Jul 13, 2026
79 of 82 checks passed
@rzikm
rzikm deleted the copilot/fix-invalid-dns-addr-array-handling branch July 13, 2026 13:20
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 14, 2026
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]>
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid DNS_ADDR_ARRAY handling

4 participants