CC: | sie [...] nic.fr |
Subject: | [PATCH] Fix compression of domain names in big packets |
Date: | Fri, 28 Nov 2008 16:23:22 +0000 |
To: | bug-Net-DNS [...] rt.cpan.org |
From: | Kim Minh Kaplan <kimminh.kaplan [...] nic.fr> |
When compressing domain names the offset must fit in 14 bits. When it
does not, compression should not be performed.
This is happens to us when composing dynamic update packets larger
than around 250 domains. The attached patch fixes this.
Kim Minh.
Index: t/04-packet.t
===================================================================
--- t/04-packet.t (révision 728)
+++ t/04-packet.t (copie de travail)
@@ -89,6 +89,13 @@
is($count2, 2, "push() returns $section RR count");
}
+# Add enough distinct labels to render compression unusable at some point
+for (0..255) {
+ $update->push('answer',
+ Net::DNS::RR->new("X$_ TXT \"" . pack("A255", "x").'"'));
+}
+$update->push('answer', Net::DNS::RR->new('XY TXT ""'));
+$update->push('answer', Net::DNS::RR->new('VW.XY TXT ""'));
# Parse data and compare with original
my $buffer = $update->data;
Index: lib/Net/DNS/Packet.pm
===================================================================
--- lib/Net/DNS/Packet.pm (révision 728)
+++ lib/Net/DNS/Packet.pm (copie de travail)
@@ -542,7 +542,7 @@
$compname .= pack('n', 0xc000 | $pointer);
last;
}
- $namehash->{$dname} = $offset;
+ $namehash->{$dname} = $offset if ($offset < 0x4000);
my $label = shift @names;
my $length = length $label || next; # skip if null