Subject: | $GENERATE padding issue |
Date: | Fri, 6 Aug 2010 11:36:01 -0400 |
To: | bug-Net-DNS-ZoneFile-Fast [...] rt.cpan.org |
From: | Chip Marshall <chip [...] 2bithacker.net> |
I think I've found a small bug in Net::DNS::ZoneFile::Fast with regards
to the $GENERATE directive processing. It appears to be space-padding
the replacement string rather than zero-padding it, which causes parsing
issues when the replacement is in the middle of a string (and inaccurate
parsing when it's at the beginning of a string.)
Example:
$GENERATE 0-31 $ PTR host${0,2,d}.example.com.
BIND expands that to
0 PTR host00.example.com.
1 PTR host01.example.com.
...
30 PTR host30.example.com.
31 PTR host31.example.com.
But with Net::DNS::ZoneFile::Fast it results in a "bad name in
PTR" parsing error. With some added debugging, I found it was
expanding to "host 0.example.com".
Module: Net-DNS-ZoneFile-Fast-1.12
Perl: v5.8.8 built for i386-freebsd-64int
OS: FreeBSD 7.0-RELEASE-p5 i386
Here's a quick patch to switch from space-padding to zero-padding:
--- Fast.pm.orig 2010-08-06 15:23:29.000000000 +0000
+++ Fast.pm 2010-08-06 15:23:42.000000000 +0000
@@ -280,7 +280,7 @@
$offset ||= 0;
$width ||= 0;
$base ||= 'd';
- sprintf "%$width$base", $offset + $from;
+ sprintf "%0$width$base", $offset + $from;
}xge;
$parse->();
$from++;
--
Chip Marshall <chip@2bithacker.net>