Perl / perl5

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

Socket::inet_aton() incorrectly accepts null string #4613

Closed p5pRT closed 20 years ago

p5pRT commented 22 years ago

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

Searchable as RT7940$

p5pRT commented 22 years ago

From Robert.Dalgleish@sk.sympatico.ca

Created by bobd@localhost.sk.sympatico.ca

inet_aton() in Socket.xs will succeed in converting a null string (pointer to null byte) to a zero address as opposed to failing (returning undef). Both the library version of inet_aton() in Mac OS X 10.1.1\, and the included my_inet_aton() in Socket.xs will cause this failure. The correct point to apply the patch is in the XS module before the null string is handed to the library function. Follows a patch to fix the my_inet_aton() and inet_aton() in Socket.xs.

*** ext/Socket/Socket.xs.orig Sat Nov 24 10​:28​:45 2001 --- ext/Socket/Socket.xs Mon Nov 26 18​:40​:07 2001 *************** *** 82\,88 ****   unsigned int parts[4];   register unsigned int *pp = parts;  
! if (!cp)   return 0;   for (;;) {   /* --- 82\,88 ----   unsigned int parts[4];   register unsigned int *pp = parts;  
! if (!cp || ! *cp)   return 0;   for (;;) {   /* *************** *** 916\,922 ****   {   struct in_addr ip_address;   struct hostent * phe; ! int ok = inet_aton(host\, &ip_address);  
  if (!ok && (phe = gethostbyname(host))) {   Copy( phe->h_addr\, &ip_address\, phe->h_length\, char ); --- 916\,922 ----   {   struct in_addr ip_address;   struct hostent * phe; ! int ok = (host != NULL) && (*host != '\0') && inet_aton(host\, &ip_address);  
  if (!ok && (phe = gethostbyname(host))) {   Copy( phe->h_addr\, &ip_address\, phe->h_length\, char ); -------

Perl Info ``` Flags: category=core severity=low Site configuration information for perl v5.6.1: Configured by bobd at Sat Nov 24 21:49:16 CST 2001. Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=darwin, osvers=5.1, archname=darwin uname='darwin localhost 5.1 darwin kernel version 5.1: tue oct 30 00:06:34 pst 2001; root:xnuxnu-201.5.obj~1release_ppc power macintosh powerpc ' config_args='-des -Dfirstmakefile=GNUmakefile -Dldflags=-flat_namespace' hint=previous, 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='cc', ccflags ='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing', optimize='-O3', cppflags='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing' ccversion='', gccversion='Apple devkit-based CPP 6.0', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags ='-flat_namespace' libpth=/usr/lib libs=-lm -lc perllibs=-lm -lc libc=/System/Library/Frameworks/System.framework/System, so=dylib, useshrplib=true, libperl=libperl.dylib Dynamic Linking: dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-flat_namespace -bundle -undefined suppress' Locally applied patches: @INC for perl v5.6.1: /System/Library/Perl/darwin /System/Library/Perl /Library/Perl/darwin /Library/Perl /Library/Perl /Network/Library/Perl/darwin /Network/Library/Perl /Network/Library/Perl . Environment for perl v5.6.1: DYLD_LIBRARY_PATH (unset) HOME=/Users/bobd LANG (unset) LANGUAGE (unset) LC_ALL=C LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=~/bin/powerpc-apple-darwin:/Users/bobd/bin:/usr/local/bin:/usr/bin:/bin :/usr/local/sbin:/usr/sbin:/sbin PERL_BADLANG (unset) SHELL=/bin/tcsh ```
p5pRT commented 22 years ago

From Robert.Dalgleish@sk.sympatico.ca

Created by bobd@localhost.sk.sympatico.ca

inet_aton() in Socket.xs will succeed in converting a null string (pointer to null byte) to a zero address as opposed to failing (returning undef). Both the library version of inet_aton() in Mac OS X 10.1.1\, and the included my_inet_aton() in Socket.xs will cause this failure. The correct point to apply the patch is in the XS module before the null string is handed to the library function. Follows a patch to fix the my_inet_aton() and inet_aton() in Socket.xs.

*** ext/Socket/Socket.xs.orig Sat Nov 24 10​:28​:45 2001 --- ext/Socket/Socket.xs Mon Nov 26 18​:40​:07 2001 *************** *** 82\,88 ****   unsigned int parts[4];   register unsigned int *pp = parts;  
! if (!cp)   return 0;   for (;;) {   /* --- 82\,88 ----   unsigned int parts[4];   register unsigned int *pp = parts;  
! if (!cp || ! *cp)   return 0;   for (;;) {   /* *************** *** 916\,922 ****   {   struct in_addr ip_address;   struct hostent * phe; ! int ok = inet_aton(host\, &ip_address);  
  if (!ok && (phe = gethostbyname(host))) {   Copy( phe->h_addr\, &ip_address\, phe->h_length\, char ); --- 916\,922 ----   {   struct in_addr ip_address;   struct hostent * phe; ! int ok = (host != NULL) && (*host != '\0') && inet_aton(host\, &ip_address);  
  if (!ok && (phe = gethostbyname(host))) {   Copy( phe->h_addr\, &ip_address\, phe->h_length\, char ); -------

Perl Info ``` Flags: category=core severity=low Site configuration information for perl v5.6.1: Configured by bobd at Sat Nov 24 21:49:16 CST 2001. Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=darwin, osvers=5.1, archname=darwin uname='darwin localhost 5.1 darwin kernel version 5.1: tue oct 30 00:06:34 pst 2001; root:xnuxnu-201.5.obj~1release_ppc power macintosh powerpc ' config_args='-des -Dfirstmakefile=GNUmakefile -Dldflags=-flat_namespace' hint=previous, 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='cc', ccflags ='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing', optimize='-O3', cppflags='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing' ccversion='', gccversion='Apple devkit-based CPP 6.0', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags ='-flat_namespace' libpth=/usr/lib libs=-lm -lc perllibs=-lm -lc libc=/System/Library/Frameworks/System.framework/System, so=dylib, useshrplib=true, libperl=libperl.dylib Dynamic Linking: dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-flat_namespace -bundle -undefined suppress' Locally applied patches: @INC for perl v5.6.1: /System/Library/Perl/darwin /System/Library/Perl /Library/Perl/darwin /Library/Perl /Library/Perl /Network/Library/Perl/darwin /Network/Library/Perl /Network/Library/Perl . Environment for perl v5.6.1: DYLD_LIBRARY_PATH (unset) HOME=/Users/bobd LANG (unset) LANGUAGE (unset) LC_ALL=C LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=~/bin/powerpc-apple-darwin:/Users/bobd/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin PERL_BADLANG (unset) SHELL=/bin/tcsh ```
p5pRT commented 22 years ago

From @jhi

Thanks\, applied. Actually the first chunk was independently fixed yesterday. Spooky.

*** ext/Socket/Socket.xs.orig Sat Nov 24 10​:28​:45 2001 --- ext/Socket/Socket.xs Mon Nov 26 18​:40​:07 2001 *************** *** 82\,88 **** unsigned int parts[4]; register unsigned int *pp = parts;

! if (!cp) return 0; for (;;) { /* --- 82\,88 ---- unsigned int parts[4]; register unsigned int *pp = parts;

! if (!cp || ! *cp) return 0; for (;;) { /* *************** *** 916\,922 **** { struct in_addr ip_address; struct hostent * phe; ! int ok = inet_aton(host\, &ip_address);

    if \(\!ok && \(phe = gethostbyname\(host\)\)\) \{
            Copy\( phe\->h\_addr\, &ip\_address\, phe\->h\_length\, char \);

--- 916\,922 ---- { struct in_addr ip_address; struct hostent * phe; ! int ok = (host != NULL) && (*host != '\0') && inet_aton(host\, &ip_address);

    if \(\!ok && \(phe = gethostbyname\(host\)\)\) \{
            Copy\( phe\->h\_addr\, &ip\_address\, phe\->h\_length\, char \);

-------

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

Configured by bobd at Sat Nov 24 21​:49​:16 CST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration​: Platform​: osname=darwin\, osvers=5.1\, archname=darwin uname='darwin localhost 5.1 darwin kernel version 5.1​: tue oct 30 00​:06​:34 pst 2001; root​:xnuxnu-201.5.obj~1release_ppc power macintosh powerpc ' config_args='-des -Dfirstmakefile=GNUmakefile -Dldflags=-flat_namespace' hint=previous\, 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='cc'\, ccflags ='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing'\, optimize='-O3'\, cppflags='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing' ccversion=''\, gccversion='Apple devkit-based CPP 6.0'\, gccosandvers='' intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=4321 d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=8 ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8 alignbytes=8\, usemymalloc=n\, prototype=define Linker and Libraries​: ld='cc'\, ldflags ='-flat_namespace' libpth=/usr/lib libs=-lm -lc perllibs=-lm -lc libc=/System/Library/Frameworks/System.framework/System\, so=dylib\, useshrplib=true\, libperl=libperl.dylib Dynamic Linking​: dlsrc=dl_dyld.xs\, dlext=bundle\, d_dlsymun=undef\, ccdlflags=' ' cccdlflags=' '\, lddlflags='-flat_namespace -bundle -undefined suppress'

Locally applied patches​:

--- @​INC for perl v5.6.1​: /System/Library/Perl/darwin /System/Library/Perl /Library/Perl/darwin /Library/Perl /Library/Perl /Network/Library/Perl/darwin /Network/Library/Perl /Network/Library/Perl .

--- Environment for perl v5.6.1​: DYLD_LIBRARY_PATH (unset) HOME=/Users/bobd LANG (unset) LANGUAGE (unset) LC_ALL=C LD_LIBRARY_PATH (unset) LOGDIR (unset)

PATH=~/bin/powerpc-apple-darwin​:/Users/bobd/bin​:/usr/local/bin​:/usr/bin​:/bin :/usr/local/sbin​:/usr/sbin​:/sbin PERL_BADLANG (unset) SHELL=/bin/tcsh

This is a bug report for perl from bobd@​localhost.sk.sympatico.ca\, generated with the help of perlbug 1.33 running under perl v5.6.1.

----------------------------------------------------------------- [Please enter your report here] inet_aton() in Socket.xs will succeed in converting a null string (pointer to null byte) to a zero address as opposed to failing (returning undef). Both the library version of inet_aton() in Mac OS X 10.1.1\, and the included my_inet_aton() in Socket.xs will cause this failure. The correct point to apply the patch is in the XS module before the null string is handed to the library function. Follows a patch to fix the my_inet_aton() and inet_aton() in Socket.xs.

*** ext/Socket/Socket.xs.orig Sat Nov 24 10​:28​:45 2001 --- ext/Socket/Socket.xs Mon Nov 26 18​:40​:07 2001 *************** *** 82\,88 **** unsigned int parts[4]; register unsigned int *pp = parts;

! if (!cp) return 0; for (;;) { /* --- 82\,88 ---- unsigned int parts[4]; register unsigned int *pp = parts;

! if (!cp || ! *cp) return 0; for (;;) { /* *************** *** 916\,922 **** { struct in_addr ip_address; struct hostent * phe; ! int ok = inet_aton(host\, &ip_address);

    if \(\!ok && \(phe = gethostbyname\(host\)\)\) \{
            Copy\( phe\->h\_addr\, &ip\_address\, phe\->h\_length\, char \);

--- 916\,922 ---- { struct in_addr ip_address; struct hostent * phe; ! int ok = (host != NULL) && (*host != '\0') && inet_aton(host\, &ip_address);

    if \(\!ok && \(phe = gethostbyname\(host\)\)\) \{
            Copy\( phe\->h\_addr\, &ip\_address\, phe\->h\_length\, char \);

-------

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

Configured by bobd at Sat Nov 24 21​:49​:16 CST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration​: Platform​: osname=darwin\, osvers=5.1\, archname=darwin uname='darwin localhost 5.1 darwin kernel version 5.1​: tue oct 30 00​:06​:34 pst 2001; root​:xnuxnu-201.5.obj~1release_ppc power macintosh powerpc ' config_args='-des -Dfirstmakefile=GNUmakefile -Dldflags=-flat_namespace' hint=previous\, 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='cc'\, ccflags ='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing'\, optimize='-O3'\, cppflags='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing' ccversion=''\, gccversion='Apple devkit-based CPP 6.0'\, gccosandvers='' intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=4321 d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=8 ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8 alignbytes=8\, usemymalloc=n\, prototype=define Linker and Libraries​: ld='cc'\, ldflags ='-flat_namespace' libpth=/usr/lib libs=-lm -lc perllibs=-lm -lc libc=/System/Library/Frameworks/System.framework/System\, so=dylib\, useshrplib=true\, libperl=libperl.dylib Dynamic Linking​: dlsrc=dl_dyld.xs\, dlext=bundle\, d_dlsymun=undef\, ccdlflags=' ' cccdlflags=' '\, lddlflags='-flat_namespace -bundle -undefined suppress'

Locally applied patches​:

--- @​INC for perl v5.6.1​: /System/Library/Perl/darwin /System/Library/Perl /Library/Perl/darwin /Library/Perl /Library/Perl /Network/Library/Perl/darwin /Network/Library/Perl /Network/Library/Perl .

--- Environment for perl v5.6.1​: DYLD_LIBRARY_PATH (unset) HOME=/Users/bobd LANG (unset) LANGUAGE (unset) LC_ALL=C LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=~/bin/powerpc-apple-darwin​:/Users/bobd/bin​:/usr/local/bin​:/usr/bin​:/bin​:/usr/local/sbin​:/usr/sbin​:/sbin PERL_BADLANG (unset) SHELL=/bin/tcsh

-- $jhi++; # http​://www.iki.fi/jhi/   # There is this special biologist word we use for 'stable'.   # It is 'dead'. -- Jack Cohen

p5pRT commented 20 years ago

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