X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/a3342be368647e67883bc6ba3bea07bb06880b80..a6bf7a5c6762f0da58cf810c3e2dd2949dd4fa92:/doio.c diff --git a/doio.c b/doio.c index 838786e..5d54a9b 100644 --- a/doio.c +++ b/doio.c @@ -126,8 +126,9 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, if (result == EOF && fd > PL_maxsysfd) { /* Why is this not Perl_warn*() call ? */ PerlIO_printf(Perl_error_log, - "Warning: unable to close filehandle %s properly.\n", - GvENAME(gv)); + "Warning: unable to close filehandle %"HEKf" properly.\n", + HEKfARG(GvENAME_HEK(gv)) + ); } IoOFP(io) = IoIFP(io) = NULL; } @@ -148,7 +149,8 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, int ismodifying; if (num_svs != 0) { - Perl_croak(aTHX_ "panic: sysopen with multiple args"); + Perl_croak(aTHX_ "panic: sysopen with multiple args, num_svs=%ld", + (long) num_svs); } /* It's not always @@ -541,14 +543,16 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw, if ((IoTYPE(io) == IoTYPE_RDONLY) && (fp == PerlIO_stdout() || fp == PerlIO_stderr())) { Perl_warner(aTHX_ packWARN(WARN_IO), - "Filehandle STD%s reopened as %s only for input", + "Filehandle STD%s reopened as %"HEKf + " only for input", ((fp == PerlIO_stdout()) ? "OUT" : "ERR"), - GvENAME(gv)); + HEKfARG(GvENAME_HEK(gv))); } else if ((IoTYPE(io) == IoTYPE_WRONLY) && fp == PerlIO_stdin()) { Perl_warner(aTHX_ packWARN(WARN_IO), - "Filehandle STDIN reopened as %s only for output", - GvENAME(gv)); + "Filehandle STDIN reopened as %"HEKf" only for output", + HEKfARG(GvENAME_HEK(gv)) + ); } } @@ -1275,30 +1279,28 @@ Perl_my_stat_flags(pTHX_ const U32 flags) io = GvIO(gv); do_fstat_have_io: PL_laststype = OP_STAT; - PL_statgv = gv; + PL_statgv = gv ? gv : (GV *)io; sv_setpvs(PL_statname, ""); if(io) { if (IoIFP(io)) { return (PL_laststatval = PerlLIO_fstat(PerlIO_fileno(IoIFP(io)), &PL_statcache)); } else if (IoDIRP(io)) { return (PL_laststatval = PerlLIO_fstat(my_dirfd(IoDIRP(io)), &PL_statcache)); - } else { - report_evil_fh(gv); - return (PL_laststatval = -1); } - } else { - report_evil_fh(gv); - return (PL_laststatval = -1); } - } - else if (PL_op->op_private & OPpFT_STACKED) { - return PL_laststatval; + PL_laststatval = -1; + report_evil_fh(gv); + return -1; } else { - SV* const sv = POPs; + SV* const sv = PL_op->op_private & OPpFT_STACKING ? TOPs : POPs; + PUTBACK; + if ((PL_op->op_private & (OPpFT_STACKED|OPpFT_AFTER_t)) + == OPpFT_STACKED) + return PL_laststatval; + else { const char *s; STRLEN len; - PUTBACK; if ((gv = MAYBE_DEREF_GV_flags(sv,flags))) { goto do_fstat; } @@ -1317,6 +1319,7 @@ Perl_my_stat_flags(pTHX_ const U32 flags) if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(s, '\n')) Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "stat"); return PL_laststatval; + } } } @@ -1336,25 +1339,25 @@ Perl_my_lstat_flags(pTHX_ const U32 flags) Perl_croak(aTHX_ no_prev_lstat); return PL_laststatval; } + PL_laststatval = -1; if (ckWARN(WARN_IO)) { - Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s", - GvENAME(cGVOP_gv)); + Perl_warner(aTHX_ packWARN(WARN_IO), + "Use of -l on filehandle %"HEKf, + HEKfARG(GvENAME_HEK(cGVOP_gv))); } - return (PL_laststatval = -1); + return -1; } - else if (PL_laststype != OP_LSTAT - && (PL_op->op_private & OPpFT_STACKED) && ckWARN(WARN_IO)) + sv = PL_op->op_private & OPpFT_STACKING ? TOPs : POPs; + PUTBACK; + if ((PL_op->op_private & (OPpFT_STACKED|OPpFT_AFTER_t)) + == OPpFT_STACKED) { + if (PL_laststype != OP_LSTAT) Perl_croak(aTHX_ no_prev_lstat); + return PL_laststatval; + } PL_laststype = OP_LSTAT; PL_statgv = NULL; - sv = POPs; - PUTBACK; - if (SvROK(sv) && isGV_with_GP(SvRV(sv)) && ckWARN(WARN_IO)) { - Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s", - GvENAME((const GV *)SvRV(sv))); - return (PL_laststatval = -1); - } file = SvPV_flags_const_nolen(sv, flags); sv_setpv(PL_statname,file); PL_laststatval = PerlLIO_lstat(file,&PL_statcache); @@ -1570,6 +1573,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp) register I32 tot = 0; const char *const what = PL_op_name[type]; const char *s; + STRLEN len; SV ** const oldmark = mark; PERL_ARGS_ASSERT_APPLY; @@ -1680,12 +1684,14 @@ nothing in the core. APPLY_TAINT_PROPER(); if (mark == sp) break; - s = SvPVx_nolen_const(*++mark); + s = SvPVx_const(*++mark, len); if (isALPHA(*s)) { - if (*s == 'S' && s[1] == 'I' && s[2] == 'G') + if (*s == 'S' && s[1] == 'I' && s[2] == 'G') { s += 3; - if ((val = whichsig(s)) < 0) - Perl_croak(aTHX_ "Unrecognized signal name \"%s\"",s); + len -= 3; + } + if ((val = whichsig_pvn(s, len)) < 0) + Perl_croak(aTHX_ "Unrecognized signal name \"%"SVf"\"", SVfARG(*mark)); } else val = SvIV(*mark); @@ -1765,7 +1771,7 @@ nothing in the core. while (++mark <= sp) { s = SvPV_nolen_const(*mark); APPLY_TAINT_PROPER(); - if (PL_euid || PL_unsafe) { + if (PerlProc_geteuid() || PL_unsafe) { if (UNLINK(s)) tot--; } @@ -1903,7 +1909,7 @@ Perl_cando(pTHX_ Mode_t mode, bool effective, register const Stat_t *statbufp) # ifdef __CYGWIN__ if (ingroup(544,effective)) { /* member of Administrators */ # else - if ((effective ? PL_euid : PL_uid) == 0) { /* root is special */ + if ((effective ? PerlProc_geteuid() : PerlProc_getuid()) == 0) { /* root is special */ # endif if (mode == S_IXUSR) { if (statbufp->st_mode & 0111 || S_ISDIR(statbufp->st_mode)) @@ -1913,7 +1919,7 @@ Perl_cando(pTHX_ Mode_t mode, bool effective, register const Stat_t *statbufp) return TRUE; /* root reads and writes anything */ return FALSE; } - if (statbufp->st_uid == (effective ? PL_euid : PL_uid) ) { + if (statbufp->st_uid == (effective ? PerlProc_geteuid() : PerlProc_getuid()) ) { if (statbufp->st_mode & mode) return TRUE; /* ok as "user" */ } @@ -1932,7 +1938,7 @@ static bool S_ingroup(pTHX_ Gid_t testgid, bool effective) { dVAR; - if (testgid == (effective ? PL_egid : PL_gid)) + if (testgid == (effective ? PerlProc_getegid() : PerlProc_getgid())) return TRUE; #ifdef HAS_GETGROUPS { @@ -2278,7 +2284,7 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp) /* suppress warning when reading into undef var (tchrist 3/Mar/00) */ if (! SvOK(mstr)) sv_setpvs(mstr, ""); - sv_upgrade(mstr, SVt_PV); + SvUPGRADE(mstr, SVt_PV); SvPOK_only(mstr); mbuf = SvGROW(mstr, (STRLEN)msize+1); @@ -2375,7 +2381,13 @@ Perl_vms_start_glob #endif #endif /* !CSH */ #endif /* !DOSISH */ - save_hash(gv_fetchpvs("ENV", 0, SVt_PVHV)); + { + GV * const envgv = gv_fetchpvs("ENV", 0, SVt_PVHV); + SV ** const home = hv_fetchs(GvHV(envgv), "HOME", 0); + if (home && *home) SvGETMAGIC(*home); + save_hash(gv_fetchpvs("ENV", 0, SVt_PVHV)); + if (home && *home) SvSETMAGIC(*home); + } (void)do_open(PL_last_in_gv, (char*)SvPVX_const(tmpcmd), SvCUR(tmpcmd), FALSE, O_RDONLY, 0, NULL); fp = IoIFP(io);