Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_dns_client - Handle null chars in raw registry dns servers value #441

Merged
merged 1 commit into from
Nov 10, 2022

Conversation

jborean93
Copy link
Collaborator

SUMMARY

If Set-DnsClientServerAddress was used to set both IPv4 and IPv6 DNS servers at the same time, the raw registry value will contain null chars. This causes problems on subsequent runs because the code will try to parse '{ip}\0\0\0\0' into a IPAddress object which fails with

{
    "changed": false,
    "msg": "Unhandled exception while executing module: Cannot convert value \"8.8.8.8\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\" to type \"System.Net.IPAddress\". Error: \"An invalid IP address was specified.\""
}

The code here trims the raw value for any null chars so the cast later one works. To replicate this you can run the following to get the host in the same state.

$adapter = Get-NetAdapter -Name 'INSERT ADAPTER NAME HERE'

$dnsServers = @(
    [System.Net.IPAddress]'8.8.4.4'
    [System.Net.IPAddress]'8.8.8.8'
    [System.Net.IPAddress]'2001:4860:4860::8888'
    [System.Net.IPAddress]'2001:4860:4860::8844'
)
Set-DnsClientServerAddress -InterfaceIndex $adapter.InterfaceIndex -ServerAddresses $dnsServers
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

win_dns_client

@jborean93 jborean93 merged commit f049245 into ansible-collections:main Nov 10, 2022
@jborean93 jborean93 deleted the dns-ipv6 branch November 10, 2022 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant