develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #109146] 3-arg open of undef for read

From:
Yitzchak Scott-Thoennes
Date:
January 26, 2012 23:55
Subject:
[perl #109146] 3-arg open of undef for read
Message ID:
rt-3.6.HEAD-14510-1327627556-739.109146-75-0@perl.org
# New Ticket Created by  Yitzchak Scott-Thoennes 
# Please include the string:  [perl #109146]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=109146 >


This is a bug report for perl from sthoenna@gmail.com,
generated with the help of perlbug 1.39 running under perl 5.14.2.


-----------------------------------------------------------------
[Please describe your issue here]

open(FH, "<", undef) triggers special behavior to open a temporary file
(at least with perlio) that is documented as only applying to +> and +<.

To keep open(FH, "<", $hash{typoedkey}) from quietly succeeding, this
should at least trigger a warning (and the doc be updated to not be mode
specific).

Crude patch from avar in irc:

diff --git a/perlio.c b/perlio.c
index a985dcc..09e415d 100644
--- a/perlio.c
+++ b/perlio.c
@@ -1601,6 +1601,8 @@ PerlIO_openn(pTHX_ const char *layers, const
char *mode, int fd,
 {
     dVAR;
     if (!f && narg == 1 && *args == &PL_sv_undef) {
+	if (mode && strEQ(mode, "r"))
+	    Perl_croak(aTHX_ "You have an undef filename with a < mode");
 	if ((f = PerlIO_tmpfile())) {
 	    if (!layers || !*layers)
 		layers = Perl_PerlIO_context_layers(aTHX_ mode);

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

Configured by ysth at Mon Dec 26 13:23:55 PST 2011.

Summary of my perl5 (revision 5 version 14 subversion 2) configuration:

  Platform:
    osname=linux, osvers=2.6.32-37-generic, archname=i686-linux
    uname='linux lark.servola.org 2.6.32-37-generic #81-ubuntu smp fri
dec 2 20:35:14 utc 2011 i686 gnulinux '
    config_args='-de -Dprefix=/home/ysth/perl5/perlbrew/perls/perl-5.14.2'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.4.3', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
/usr/lib/i486-linux-gnu /usr/lib64
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.11.1.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.11.1'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'

Locally applied patches:


---
@INC for perl 5.14.2:
    /usr/lib/shiftboard
    /home/ysth/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/i686-linux
    /home/ysth/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2
    /home/ysth/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/i686-linux
    /home/ysth/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2
    .

---
Environment for perl 5.14.2:
    HOME=/home/ysth
    LANG=en_US.utf8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/ysth/perl5/perlbrew/bin:/home/ysth/perl5/perlbrew/perls/current/bin:/home/ysth/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    PERL5LIB=/usr/lib/shiftboard
    PERLBREW_PATH=/home/ysth/perl5/perlbrew/bin:/home/ysth/perl5/perlbrew/perls/current/bin
    PERLBREW_PERL=perl-5.14.2
    PERLBREW_ROOT=/home/ysth/perl5/perlbrew
    PERLBREW_VERSION=0.18
    PERL_BADLANG (unset)
    SHELL=/bin/bash




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About