mirror of
https://github.com/danog/dns.git
synced 2024-11-26 20:14:51 +01:00
Allow empty domain names to be decoded
This is a rather long standing issue. LibDNS didn't allow to decode empty domain names. Empty domain names were previously only observed with PTR records, but were now also observed in regular queries in authoritative records that include the root nameservers. LibDNS 2.0 mainly adds scalar types has just a few breaking changes. We don't expose it anywhere, so an upgrade is perfectly fine. Fixes #53.
This commit is contained in:
parent
16e6d6c22f
commit
2c8133a7b4
@ -42,7 +42,7 @@
|
||||
"amphp/parser": "^1",
|
||||
"amphp/uri": "^0.1",
|
||||
"amphp/windows-registry": "^0.3",
|
||||
"daverandom/libdns": "^1"
|
||||
"daverandom/libdns": "^2.0.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"amphp/phpunit-util": "^1",
|
||||
|
@ -237,7 +237,7 @@ abstract class Socket {
|
||||
return false;
|
||||
}
|
||||
|
||||
$questionRecord = $questionRecords->current();
|
||||
$questionRecord = $questionRecords->getIterator()->current();
|
||||
|
||||
if ($questionRecord->getClass() !== $question->getClass()) {
|
||||
return false;
|
||||
|
21
test/DecodeTest.php
Normal file
21
test/DecodeTest.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Dns\Test;
|
||||
|
||||
use Amp\PHPUnit\TestCase;
|
||||
use LibDNS\Decoder\DecoderFactory;
|
||||
use LibDNS\Messages\Message;
|
||||
|
||||
class DecodeTest extends TestCase {
|
||||
/**
|
||||
* Regression test for https://github.com/amphp/dns/issues/53 and other reported issues.
|
||||
*/
|
||||
public function testDecodesEmptyDomains() {
|
||||
$message = hex2bin("37ed818000010005000d000005676d61696c03636f6d00000f0001c00c000f000100000dff0020000a04616c74310d676d61696c2d736d74702d696e016c06676f6f676c65c012c00c000f000100000dff0009001404616c7432c02ec00c000f000100000dff0009002804616c7434c02ec00c000f000100000dff0009001e04616c7433c02ec00c000f000100000dff00040005c02e0000020001000026b50014016c0c726f6f742d73657276657273036e6574000000020001000026b500040163c0a30000020001000026b500040164c0a30000020001000026b50004016ac0a30000020001000026b500040162c0a30000020001000026b500040161c0a30000020001000026b500040167c0a30000020001000026b50004016bc0a30000020001000026b500040165c0a30000020001000026b50004016dc0a30000020001000026b500040169c0a30000020001000026b500040166c0a30000020001000026b500040168c0a3");
|
||||
|
||||
$decoder = (new DecoderFactory)->create();
|
||||
$response = $decoder->decode($message);
|
||||
|
||||
$this->assertInstanceOf(Message::class, $response);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user