Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.93k stars 551 forks source link

5.6.1 question with inet_aton (Socket module) #4610

Closed p5pRT closed 12 years ago

p5pRT commented 22 years ago

Migrated from rt.perl.org#7937 (status was 'resolved')

Searchable as RT7937$

p5pRT commented 22 years ago

From perl@neuron.mct.rochester.edu

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl v5.6.1: Configured by perl at Thu Nov 22 15:18:16 EST 2001. Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=solaris, osvers=2.6, archname=sun4-solaris uname='sunos neuron.mct.rochester.edu 5.6 generic_105181-28 sun4u sparc sunw,ultra-250 ' config_args='-des -Dcc=gcc -Dprefix=/usr/mct1/perl -Dotherlibdirs=/u/develop/develop/study_tk/lib:/usr/mct1/www/neuron/conf:/usr/mct1/www/neuron/lib/perl' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='gcc', ccflags =' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O', cppflags='' ccversion='', gccversion='2.8.1', gccosandvers='solaris2.6' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, usemymalloc=y, prototype=define Linker and Libraries: ld='gcc', ldflags =' ' libpth=/usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lc perllibs=-lsocket -lnsl -ldl -lm -lc libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-fPIC', lddlflags='-G' Locally applied patches: @INC for perl v5.6.1: /usr/mct1/www/neuron/lib/perl /u/develop/develop/study_tk/lib /usr/mct1/perl/lib/5.6.1/sun4-solaris /usr/mct1/perl/lib/5.6.1 /usr/mct1/perl/lib/site_perl/5.6.1/sun4-solaris /usr/mct1/perl/lib/site_perl/5.6.1 /usr/mct1/perl/lib/site_perl /u/develop/develop/study_tk/lib /usr/mct1/www/neuron/conf /usr/mct1/www/neuron/lib/perl . Environment for perl v5.6.1: HOME=/usr/mct1/cpan LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH=/usr/mct1/lib:/usr/license1/ingres2/ingres/lib LOGDIR (unset) PATH=/usr/mct1/perl/bin:/usr/mct1/scripts:/usr/mct1/bin:/usr/mct1/www/neuron/bin:/u/develop/develop/study_tk/bin:/usr/bin:/usr/openwin/bin:/usr/ucb:/usr/license1/ingres2/ingres/bin:/usr/license1/ingres2/ingres/utility:/usr/mct/bin:/usr/mct1/samba/bin:/usr/ccs/bin:/usr/license2/wp7/wpbin PERL5LIB=/usr/mct1/www/neuron/lib/perl:/u/develop/develop/study_tk/lib PERL_BADLANG (unset) SHELL=/usr/mct1/bin/tcsh ```
p5pRT commented 12 years ago

From @Hugmeir

On Mon Nov 26 05​:34​:26 2001\, perl@​neuron.mct.rochester.edu wrote​:

I expected this program to NOT print anything\, but it does\, and it seems to possibly point to a bug. The man page for Socket says that inet_aton should return undef​: "If the host name cannot be resolved\, returns undef." My program uses a hostname of "undef"\, which to me should mean that it cannot be resolved. I also confirmed this behavior is the same for perl 5.005_03 (on the same machine). The issue does NOT seem to be present with perl 5.6.0 on i386-linux.

use  Socket;
if \($host=inet\_aton\(undef\)\) \{
      printf "Socket version=%s\\n"\,$Socket​::VERSION;
      printf "not OK\, host=%s\\n"\,join\('\.'\,unpack\('C4'\,$host\)\);
\}

Here's the output from this program​:

Socket version=1\.72
not OK\, host=0\.0\.0\.0

Eric Lenio

----------------------------------------------------------------- [Please enter your report here]

[Please do not change anything below this line] ----------------------------------------------------------------- --- Flags​: category=core severity=medium --- Site configuration information for perl v5.6.1​:

Configured by perl at Thu Nov 22 15​:18​:16 EST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration​: Platform​: osname=solaris\, osvers=2.6\, archname=sun4-solaris uname='sunos neuron.mct.rochester.edu 5.6 generic_105181-28 sun4u sparc sunw\,ultra-250 ' config_args='-des -Dcc=gcc -Dprefix=/usr/mct1/perl

-Dotherlibdirs=/u/develop/develop/study_tk/lib​:/usr/mct1/www/neuron/conf​:/usr/mct1/www/neuron/lib/perl' hint=recommended\, useposix=true\, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler​: cc='gcc'\, ccflags =' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'\, optimize='-O'\, cppflags='' ccversion=''\, gccversion='2.8.1'\, gccosandvers='solaris2.6' intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=4321 d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=16 ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8 alignbytes=8\, usemymalloc=y\, prototype=define Linker and Libraries​: ld='gcc'\, ldflags =' ' libpth=/usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lc perllibs=-lsocket -lnsl -ldl -lm -lc libc=/lib/libc.so\, so=so\, useshrplib=false\, libperl=libperl.a Dynamic Linking​: dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags=' ' cccdlflags='-fPIC'\, lddlflags='-G'

Locally applied patches​:

--- @​INC for perl v5.6.1​: /usr/mct1/www/neuron/lib/perl /u/develop/develop/study_tk/lib /usr/mct1/perl/lib/5.6.1/sun4-solaris /usr/mct1/perl/lib/5.6.1 /usr/mct1/perl/lib/site_perl/5.6.1/sun4-solaris /usr/mct1/perl/lib/site_perl/5.6.1 /usr/mct1/perl/lib/site_perl /u/develop/develop/study_tk/lib /usr/mct1/www/neuron/conf /usr/mct1/www/neuron/lib/perl .

--- Environment for perl v5.6.1​: HOME=/usr/mct1/cpan LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH=/usr/mct1/lib​:/usr/license1/ingres2/ingres/lib LOGDIR (unset)

PATH=/usr/mct1/perl/bin​:/usr/mct1/scripts​:/usr/mct1/bin​:/usr/mct1/www/neuron/bin​:/u/develop/develop/study_tk/bin​:/usr/bin​:/usr/openwin/bin​:/usr/ucb​:/usr/license1/ingres2/ingres/bin​:/usr/license1/ingres2/ingres/utility​:/usr/mct/bin​:/usr/mct1/samba/bin​:/usr/ccs/bin​:/usr/license2/wp7/wpbin PERL5LIB=/usr/mct1/www/neuron/lib/perl​:/u/develop/develop/study_tk/lib PERL_BADLANG (unset) SHELL=/usr/mct1/bin/tcsh

hugmeir@​global​:\~/perl-blead$ perlbrew exec ~/perl-blead/7937.pl perl-5.10.1-gcc

perl-5.10.1-suncc

perl-5.12.4-gcc

perl-5.12.4-suncc

perl-5.14.2-gcc

perl-5.14.2-suncc

Same result with the 5.8.4 that comes with Solaris 10. So it appears that this was already fixed. I vote to close this.

p5pRT commented 12 years ago

@cpansprout - Status changed from 'open' to 'resolved'

p5pRT commented 12 years ago

From @nwc10

On Sat\, Apr 28\, 2012 at 01​:54​:58AM -0700\, Brian Fraser via RT wrote​:

On Mon Nov 26 05​:34​:26 2001\, perl@​neuron.mct.rochester.edu wrote​:

I expected this program to NOT print anything\, but it does\, and it seems to possibly point to a bug. The man page for Socket says that inet_aton should return undef​: "If the host name cannot be resolved\, returns undef." My program uses a hostname of "undef"\, which to me should mean that it cannot be resolved. I also confirmed this behavior is the same for perl 5.005_03 (on the same machine). The issue does NOT seem to be present with perl 5.6.0 on i386-linux.

Same result with the 5.8.4 that comes with Solaris 10. So it appears that this was already fixed. I vote to close this.

I build 5.005_03 (mentioned in the bug report as failing) on Solaris and it "works on my machine". So I don't think that was fixed by us.

I'm suspicious that it was fixed by Sun. undef will stringify to the empty string. Did Solaris used to resolve the empty string as 0.0.0.0?

Nicholas Clark

p5pRT commented 12 years ago

From @doughera88

On Tue\, 1 May 2012\, Nicholas Clark wrote​:

On Sat\, Apr 28\, 2012 at 01​:54​:58AM -0700\, Brian Fraser via RT wrote​:

On Mon Nov 26 05​:34​:26 2001\, perl@​neuron.mct.rochester.edu wrote​:

I expected this program to NOT print anything\, but it does\, and it seems to possibly point to a bug. The man page for Socket says that inet_aton should return undef​: "If the host name cannot be resolved\, returns undef." My program uses a hostname of "undef"\, which to me should mean that it cannot be resolved. I also confirmed this behavior is the same for perl 5.005_03 (on the same machine). The issue does NOT seem to be present with perl 5.6.0 on i386-linux.

Same result with the 5.8.4 that comes with Solaris 10. So it appears that this was already fixed. I vote to close this.

I build 5.005_03 (mentioned in the bug report as failing) on Solaris and it "works on my machine". So I don't think that was fixed by us.

It failed for me with 5.005_03 on Solaris 8/SPARC\, but passed with 5.8.6. Git bisect stopped with this unhelpful message​:

  The merge base 8e09340b6ffe3c6ffbac698cf506650fc1e43293 is bad.   This means the bug has been fixed between 8e09340b6ffe3c6ffbac698cf506650fc1e43293 and [02a834a9ae508dc3fab0b5a0375804172985b012].

(i.e. between 5.005 and 5.8.0). Alas it's not obvious to me what the next step is. I'll poke at it a bit intermittently today to see if I can coax any more information out of it.

I'm suspicious that it was fixed by Sun. undef will stringify to the empty string. Did Solaris used to resolve the empty string as 0.0.0.0?

What architecture did you test on? There may well be some sort of SPARC/x86 difference here.

--   Andy Dougherty doughera@​lafayette.edu

p5pRT commented 12 years ago

From @doughera88

On Fri\, 4 May 2012\, Andy Dougherty wrote​:

On Tue\, 1 May 2012\, Nicholas Clark wrote​:

On Sat\, Apr 28\, 2012 at 01​:54​:58AM -0700\, Brian Fraser via RT wrote​:

On Mon Nov 26 05​:34​:26 2001\, perl@​neuron.mct.rochester.edu wrote​:

I expected this program to NOT print anything\, but it does\, and it seems to possibly point to a bug. The man page for Socket says that inet_aton should return undef​: "If the host name cannot be resolved\, returns undef." My program uses a hostname of "undef"\, which to me should mean that it cannot be resolved. I also confirmed this behavior is the same for perl 5.005_03 (on the same machine). The issue does NOT seem to be present with perl 5.6.0 on i386-linux.

Same result with the 5.8.4 that comes with Solaris 10. So it appears that this was already fixed. I vote to close this.

I build 5.005_03 (mentioned in the bug report as failing) on Solaris and it "works on my machine". So I don't think that was fixed by us.

It failed for me with 5.005_03 on Solaris 8/SPARC\, but passed with 5.8.6. Git bisect stopped with this unhelpful message​:

The merge base 8e09340b6ffe3c6ffbac698cf506650fc1e43293 is bad\.
This means the bug has been fixed between 8e09340b6ffe3c6ffbac698cf506650fc1e43293 and \[02a834a9ae508dc3fab0b5a0375804172985b012\]\.

(i.e. between 5.005 and 5.8.0). Alas it's not obvious to me what the next step is. I'll poke at it a bit intermittently today to see if I can coax any more information out of it.

Solved. Craig fixed it with this simple commit. I'll close the ticket.

commit dfb6a7ef48035acda2858c343a48352b20f2b43f Author​: Craig A. Berry \craigberry@​mac\.com Date​: Sun Nov 25 10​:20​:45 2001 -0600

  Socket​::my_inet_aton() tweak   Message-Id​: \5\.1\.0\.14\.2\.20011125160848\.01c59690@​exchi01  
  p4raw-id​: //depot/perl@​13275

Inline Patch ```diff diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index 73cf320..4191097 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @@ -87,7 +87,7 @@ my_inet_aton(register const char *cp, struct in_addr *addr) unsigned int parts[4]; register unsigned int *pp = parts; - if (!cp) + if (!cp || !*cp) return 0; for (;;) { /* -- ```

  Andy Dougherty doughera@​lafayette.edu

p5pRT commented 12 years ago

From @nwc10

On Fri\, May 04\, 2012 at 11​:43​:24AM -0400\, Andy Dougherty wrote​:

On Fri\, 4 May 2012\, Andy Dougherty wrote​:

On Tue\, 1 May 2012\, Nicholas Clark wrote​:

On Sat\, Apr 28\, 2012 at 01​:54​:58AM -0700\, Brian Fraser via RT wrote​:

Same result with the 5.8.4 that comes with Solaris 10. So it appears that this was already fixed. I vote to close this.

I build 5.005_03 (mentioned in the bug report as failing) on Solaris and it "works on my machine". So I don't think that was fixed by us.

It failed for me with 5.005_03 on Solaris 8/SPARC\, but passed with 5.8.6. Git bisect stopped with this unhelpful message​:

The merge base 8e09340b6ffe3c6ffbac698cf506650fc1e43293 is bad\.
This means the bug has been fixed between 8e09340b6ffe3c6ffbac698cf506650fc1e43293 and \[02a834a9ae508dc3fab0b5a0375804172985b012\]\.

Is that from trying to bisect with a start of 5.005_o3 and an end of 5.8.6?

(i.e. between 5.005 and 5.8.0). Alas it's not obvious to me what the next step is. I'll poke at it a bit intermittently today to see if I can coax any more information out of it.

Solved. Craig fixed it with this simple commit. I'll close the ticket.

Thanks for nailing this.

commit dfb6a7ef48035acda2858c343a48352b20f2b43f Author​: Craig A. Berry \craigberry@​mac\.com Date​: Sun Nov 25 10​:20​:45 2001 -0600

Socket​::my\_inet\_aton\(\) tweak
Message\-Id&#8203;: \<5\.1\.0\.14\.2\.20011125160848\.01c59690@&#8203;exchi01>

p4raw\-id&#8203;: //depot/perl@&#8203;13275

diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index 73cf320..4191097 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @​@​ -87\,7 +87\,7 @​@​ my_inet_aton(register const char *cp\, struct in_addr *addr) unsigned int parts[4]; register unsigned int *pp = parts;

- if (!cp) + if (!cp || !*cp) return 0; for (;;) { /*

I don't see any difference on the x86 Solaris 11 machine I have access to​: $ uname -a SunOS solaris1164 5.11 snv_151a i86pc i386 i86pc Solaris

It may be because that code in Socket.xs isn't reached\, due to this​:

$ grep HAS_INET_ATON config.h /* HAS_INET_ATON​: #define HAS_INET_ATON /**/

Is HAS_INET_ATON undef on Solaris 8?

Nicholas Clark

p5pRT commented 12 years ago

From @smpeters

On Fri\, May 4\, 2012 at 11​:02 AM\, Nicholas Clark \nick@&#8203;ccl4\.org wrote​:

On Fri\, May 04\, 2012 at 11​:43​:24AM -0400\, Andy Dougherty wrote​:

On Fri\, 4 May 2012\, Andy Dougherty wrote​:

On Tue\, 1 May 2012\, Nicholas Clark wrote​:

On Sat\, Apr 28\, 2012 at 01​:54​:58AM -0700\, Brian Fraser via RT wrote​:

Same result with the 5.8.4 that comes with Solaris 10. So it appears that this was already fixed. I vote to close this.

I build 5.005_03 (mentioned in the bug report as failing) on Solaris and it "works on my machine". So I don't think that was fixed by us.

It failed for me with 5.005_03 on Solaris 8/SPARC\, but passed with 5.8.6. Git bisect stopped with this unhelpful message​:

The merge base 8e09340b6ffe3c6ffbac698cf506650fc1e43293 is bad\.
This means the bug has been fixed between

8e09340b6ffe3c6ffbac698cf506650fc1e43293 and [02a834a9ae508dc3fab0b5a0375804172985b012].

Is that from trying to bisect with a start of 5.005_o3 and an end of 5.8.6?

(i.e. between 5.005 and 5.8.0). Alas it's not obvious to me what the next step is. I'll poke at it a bit intermittently today to see if I can coax any more information out of it.

Solved. Craig fixed it with this simple commit. I'll close the ticket.

Thanks for nailing this.

commit dfb6a7ef48035acda2858c343a48352b20f2b43f Author​: Craig A. Berry \craigberry@&#8203;mac\.com Date​: Sun Nov 25 10​:20​:45 2001 -0600

Socket&#8203;::my\_inet\_aton\(\) tweak
Message\-Id&#8203;: \<5\.1\.0\.14\.2\.20011125160848\.01c59690@&#8203;exchi01>

p4raw\-id&#8203;: //depot/perl@&#8203;13275

diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index 73cf320..4191097 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @​@​ -87\,7 +87\,7 @​@​ my_inet_aton(register const char *cp\, struct in_addr *addr) unsigned int parts[4]; register unsigned int *pp = parts;

- if (!cp) + if (!cp || !*cp) return 0; for (;;) { /*

I don't see any difference on the x86 Solaris 11 machine I have access to​: $ uname -a SunOS solaris1164 5.11 snv_151a i86pc i386 i86pc Solaris

It may be because that code in Socket.xs isn't reached\, due to this​:

$ grep HAS_INET_ATON config.h /* HAS_INET_ATON​: #define HAS_INET_ATON /**/

Is HAS_INET_ATON undef on Solaris 8?

It does\, but it is in libresolve. I dug up this old Samba mailing list discussion of the problem http​://lists.samba.org/archive/samba-technical/2001-January/011680.html

Steve Peters steve@​fisharerojo.org

p5pRT commented 12 years ago

From @doughera88

On Fri\, 4 May 2012\, Nicholas Clark wrote​:

commit dfb6a7ef48035acda2858c343a48352b20f2b43f Author​: Craig A. Berry \craigberry@&#8203;mac\.com Date​: Sun Nov 25 10​:20​:45 2001 -0600

Socket&#8203;::my\_inet\_aton\(\) tweak
Message\-Id&#8203;: \<5\.1\.0\.14\.2\.20011125160848\.01c59690@&#8203;exchi01>

p4raw\-id&#8203;: //depot/perl@&#8203;13275

diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index 73cf320..4191097 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @​@​ -87\,7 +87\,7 @​@​ my_inet_aton(register const char *cp\, struct in_addr *addr) unsigned int parts[4]; register unsigned int *pp = parts;

- if (!cp) + if (!cp || !*cp) return 0; for (;;) { /*

I don't see any difference on the x86 Solaris 11 machine I have access to​: $ uname -a SunOS solaris1164 5.11 snv_151a i86pc i386 i86pc Solaris

It may be because that code in Socket.xs isn't reached\, due to this​:

$ grep HAS_INET_ATON config.h /* HAS_INET_ATON​: #define HAS_INET_ATON /**/

Is HAS_INET_ATON undef on Solaris 8?

Yup\, that's it. The guilty code is buried in a rarely-used #ifndef/#endif bracket.

--   Andy Dougherty doughera@​lafayette.edu

p5pRT commented 12 years ago

From @craigberry

On Fri\, May 4\, 2012 at 12​:17 PM\, Andy Dougherty \doughera@&#8203;lafayette\.edu wrote​: On Fri\, 4 May 2012\, Nicholas Clark wrote​:

commit dfb6a7ef48035acda2858c343a48352b20f2b43f Author​: Craig A. Berry \craigberry@&#8203;mac\.com Date​:   Sun Nov 25 10​:20​:45 2001 -0600

    Socket​::my_inet_aton() tweak     Message-Id​: \5\.1\.0\.14\.2\.20011125160848\.01c59690@&#8203;exchi01

    p4raw-id​: //depot/perl@​13275

diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index 73cf320..4191097 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @​@​ -87\,7 +87\,7 @​@​ my_inet_aton(register const char *cp\, struct in_addr *addr)     unsigned int parts[4];     register unsigned int *pp = parts;

-   if (!cp) +       if (!cp || !*cp)             return 0;     for (;;) {             /*

I don't see any difference on the x86 Solaris 11 machine I have access to​: $ uname -a SunOS solaris1164 5.11 snv_151a i86pc i386 i86pc Solaris

It may be because that code in Socket.xs isn't reached\, due to this​:

$ grep HAS_INET_ATON config.h /* HAS_INET_ATON​: #define HAS_INET_ATON           /**/

Is HAS_INET_ATON undef on Solaris 8?

Yup\, that's it.  The guilty code is buried in a rarely-used #ifndef/#endif bracket.

From the mail that accompanied the patch​:

On Sun\, Nov 25\, 2001 at 04​:20​:45PM -0600\, Craig A. Berry wrote​:

my_inet_aton() was accepting a zero-length host name and successfully converting it to an address of all zeroes.  This is apparently not the expected behavior since test #4 in lib/Net/t/config.t expressly uses a zero-length string as an invalid hostname and the test was failing.  It passes after the following patch.  Note that this only affects platforms where HAS_INET_ATON is false.