Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 28198
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: OLAF [...] cpan.org
Requestors: bb [...] otrs.com
medwards [...] nasba.org
sec [...] 42.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Modification of a read-only value attempted at /usr/local/lib/perl/5.8.8/Net/DNS/Question.pm line 47
Date: Wed, 11 Jul 2007 17:12:43 +0200
To: bug-Net-DNS [...] rt.cpan.org
From: Bodo Bauer <bb [...] otrs.com>
Download signature.asc
application/pgp-signature 189b

Message body not shown because it is not plain text.

Hi, OTRS utilizes Net::DNS to check if a host name is valid (for email address entries). Up to version 0.59 this worked perfectly well. Version 0.60 throws an error: Modification of a read-only value attempted at /usr/local/lib/perl/5.8.8/Net/DNS/Question.pm line 47 Strangely enough this only happens if the script runs in the Web Server environment. I wasn't able to reproduce it in a 'regular' script. The issue is that $_ in modified at a few places. This is where the module breaks. Attached is a small patch wich fixes the issue. Not sure I caught all occurrences. But at least the ones we use are fixed :) Modifying $_ is deprecated anyway, so I think it's a good direction to be headed for. IIRC, Perl 6 is supposed to enforce this policy anyway. Cheers, BB

Message body is not shown because sender requested not to inline it.

Subject: [rt.cpan.org #28106] Reference to OTRS Bugzilla
Date: Wed, 11 Jul 2007 17:55:34 +0200
To: bug-Net-DNS [...] rt.cpan.org
From: Bodo Bauer <bb [...] otrs.com>
Here is a reference to the referring bug in our Bugzilla: http://bugs.otrs.org/show_bug.cgi?id=2017
Download signature.asc
application/pgp-signature 189b

Message body not shown because it is not plain text.

Subject: Net::DNS bug in v.60 with $_
Date: Sat, 14 Jul 2007 13:53:57 +0200
To: bug-Net-DNS [...] rt.cpan.org
From: Stefan `Sec` Zehl <sec [...] 42.org>
Hi, There is a bug with the new Net::DNS v.60 - It improperly uses $_ inside, and thus overwrites the Callers $_ variable. One (easy) example is: | ice:~>perl -MNet::DNS -we 'use strict; | my $res=new Net::DNS::Resolver; | for (0){ | my $q=$res->send("freebsd.org","A"); | } | ' Modification of a read-only value attempted at /usr/local/lib/perl5/site_perl/5.8.8/mach/Net/DNS/Question.pm line 47. If you instead add a variable to the for loop, it runs as expected. CU, Sec P.S.: some system info, in case you need it: ice:~>uname -a FreeBSD ice 6.2-STABLE FreeBSD 6.2-STABLE #38: Sun Feb 25 09:20:09 CET 2007 root@ice:/export/obj/export/src/sys/ICE i386 ice:~>pkg_info -aI|grep Net-DNS p5-Net-DNS-0.60 Perl5 interface to the DNS resolver, and dynamic updates ice:~>perl -V Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=freebsd, osvers=6.2-prerelease, archname=i386-freebsd-64int uname='freebsd ice 6.2-prerelease freebsd 6.2-prerelease #36: sun oct 1 00:50:35 cest 2006 root@:exportobjexportsrcsysice i386 ' config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-O2 -fno-strict-aliasing -pipe -march=k6 -Ud_dosuid -Ui_gdbm -Dusethreads=n -Dusemymalloc=y -Duse64bitint' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=undef uselongdouble=undef usemymalloc=y, bincompat5005=undef Compiler: cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include', optimize='-O2 -fno-strict-aliasing -pipe -march=k6', cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include' ccversion='', gccversion='3.4.6 [FreeBSD] 20060305', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -Wl,-E -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lgdbm -lm -lcrypt -lutil perllibs=-lm -lcrypt -lutil libc=, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE' cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MYMALLOC PERL_MALLOC_WRAP USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO Locally applied patches: defined-or Built under freebsd Compiled at Oct 1 2006 02:28:53 @INC: /usr/local/lib/perl5/5.8.8/BSDPAN /usr/local/lib/perl5/site_perl/5.8.8/mach /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl/5.8.7 /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl/5.8.5 /usr/local/lib/perl5/site_perl/5.8.4 /usr/local/lib/perl5/site_perl/5.8.2 /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.8.8/mach /usr/local/lib/perl5/5.8.8 . -- Failure is not an option. It comes bundled with your Microsoft product.
Subject: $_ inadvertently altered leading to side effects in calling program
I've isolated and patched a somewhat obscure bug in the most recent (0.60) Net::DNS package. Calling mx() either as a function or a method overwrites the current value of $_ with the IP address of the DNS server that responded to the query. I haven't checked all the functions the package provides, but I know this effect is at least produced by the mx() function. Consider this code fragment: --- snip --- use strict; use warnings; use Net::DNS; my @a = ( { 'name' => 'www.google.com' }, { 'name' => 'www.yahoo.com' } ); foreach (@a) { print mx($_->{name}) . " is the ip for $_->{'name'}\n"; } --- snip --- Because the mx function overwrites the value of $_, we get a runtime error when we try to use $_ as a hash reference after the function call: Can't use string ("192.168.1.3") as a HASH ref while "strict refs" in use at - line 13. Further, since in the foreach loop $_ is an alias for each array entry, the mx function has also inadvertently overwritten the contents of @a. Since $_ in a true global variable, avoiding its use in the foreach only allows the alteration of $_ to manifest itself somewhere else. In my case it appeared 4 method calls above a call to Email::Valid::address(), which uses Net::DNS internally to verify that the domain name exists. Below are the 3 places I've found where alterations to $_ occur and the alterations I made to prevent it. In Net::DNS::Question::new() replace my $qname = defined ($_ = shift) ? $_ : ''; with my $qname = shift; $qname = '' unless defined ($qname); In Net::DNS::Resolver::Base in _ip_is_ipv4() and _ip_is_ipv6() replace $_ = shift; with local $_ = shift; This effect is most likely platform neutral, but it has appeared for me in perl 5.8.8 on Gentoo and CentOs Linux, with the above snippet pasted directly into perl and under various minor revisions of mod_perl and apache 2. Please let me know if there is anything I can do to help.
Subject: $_ inadvertently altered leading to side effects in calling program
I've isolated and patched a somewhat obscure bug in the most recent (0.60) Net::DNS package. Calling mx() either as a function or a method overwrites the current value of $_ with the IP address of the DNS server that responded to the query. I haven't checked all the functions the package provides, but I know this effect is at least produced by the mx() function. Consider this code fragment: --- snip --- use strict; use warnings; use Net::DNS; my @a = ( { 'name' => 'www.google.com' }, { 'name' => 'www.yahoo.com' } ); foreach (@a) { print mx($_->{name}) . " is the ip for $_->{'name'}\n"; } --- snip --- Because the mx function overwrites the value of $_, we get a runtime error when we try to use $_ as a hash reference after the function call: Can't use string ("192.168.1.3") as a HASH ref while "strict refs" in use at - line 13. Further, since in the foreach loop $_ is an alias for each array entry, the mx function has also inadvertently overwritten the contents of @a. Since $_ in a true global variable, avoiding its use in the foreach only allows the alteration of $_ to manifest itself somewhere else. In my case it appeared 4 method calls above a call to Email::Valid::address(), which uses Net::DNS internally to verify that the domain name exists. Below are the 3 places I've found where alterations to $_ occur and the alterations I made to prevent it. In Net::DNS::Question::new() replace my $qname = defined ($_ = shift) ? $_ : ''; with my $qname = shift; $qname = '' unless defined ($qname); In Net::DNS::Resolver::Base in _ip_is_ipv4() and _ip_is_ipv6() replace $_ = shift; with local $_ = shift; This effect is most likely platform neutral, but it has appeared for me in perl 5.8.8 on Gentoo and CentOs Linux, with the above snippet pasted directly into perl and under various minor revisions of mod_perl and apache 2. Please let me know if there is anything I can do to help.
Fixed in Net::DNS 0.61 Just released
Subject: Re: [rt.cpan.org #28198] Net::DNS bug in v.60 with $_
Date: Wed, 1 Aug 2007 16:08:59 +0200
To: Olaf Kolkman via RT <bug-Net-DNS [...] rt.cpan.org>
From: Stefan `Sec` Zehl <sec [...] 42.org>
On Wed, Aug 01, 2007 at 09:45 -0400, Olaf Kolkman via RT wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=28198 > > > Fixed in Net::DNS 0.61 > > Just released
Thanks! CU, Sec -- In 1968 it took the computing-Power of 2 C-64 to fly a rocket to the moon. Now, 1997 it takes the Power of a Pentium 133 to run Microsoft Windows 95. Something must have gone wrong.
Fixed in 0.61.. some time ago...