question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ArgumentException parsing a valid DNS data

See original GitHub issue

I have upgraded to V3, it is great having TXT fields abstraction. But in some domains, it is throwing an ArgumentException: “Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.”

I found that it is happening when CharacterString.GetAllFromArray() is called

https://github.com/kapetan/dns/blob/8ae198c54b627e05ab8fe843e3d321171255f007/DNS/Protocol/ResourceRecords/TextResourceRecord.cs#L43-L46

For example, for makingsense.com., of message in base64 is IA+BgAABAAIAAAAAC21ha2luZ3NlbnNlA2NvbQAAEAABwAwAEAABAAADnQBFRGdvb2dsZS1zaXRlLXZlcmlmaWNhdGlvbj1mUTZtaEFzOWlZTEZOWklZSFhJX28yMXNuVUtZbGE5TGgtMDZxOUJWNUpVwAwAEAABAAADnQBAP3Y9c3BmMSBpbmNsdWRlOnNwZi5mcm9tZG9wcGxlci5jb20gaW5jbHVkZTpfc3BmLmdvb2dsZS5jb20gfmFsbA== and offset is 45.

Going deeper, in the 2nd iteration of CharacterString.FromArray()

https://github.com/kapetan/dns/blob/8ae198c54b627e05ab8fe843e3d321171255f007/DNS/Protocol/CharacterString.cs#L38-L48

len take value of 192, but offset is 115 and message.Length is 190, so Buffer.BlockCopy(message, offset, data, 0, len); throws the ArgumentException.

There are a lot of DNS that are throwing that error, I am not sure if DNS data is fine or not, but other tools are reading it fine, for example in this case with MXToolbox.

I would be glad to create a PR with a fix, but my knowledge about DNS standards ir limited.

Do you think that it is possible to apply a workaround to fix or mitigate it?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kapetancommented, Feb 6, 2018

Thanks for reporting this issue, I’ll take a look.

0reactions
andresmoschinicommented, Apr 4, 2018

Thanks, good job!

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - What is the best way of validating an IP Address?
TryParse method is that it verifies if a string could be converted to IP address, thus if it is supplied with a string...
Read more >
Dns.GetHostEntry Method (System.Net)
The GetHostEntry method queries a DNS server for the IP addresses and aliases associated with ... The hostNameOrAddress parameter is an invalid IP...
Read more >
Classes inheriting TcpClient or Sockets don't function using ...
ArgumentException : None of the discovered or specified addresses match the socket address family. Parameter name: context at System.Runtime.
Read more >
SqlConnection.ConnectionString Property
Keyword Default Description Addr N/A Synonym of Data Source. Address N/A Synonym of Data Source. App N/A Synonym of Application Name.
Read more >
Unable to parse zone?
The error means that the dns zone has invalid data in it and it cannot be loaded. So you need to recreate the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found