diff options
author | Chip Salzenberg <chip@pobox.com> | 2008-12-01 07:01:12 -0800 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2008-12-13 14:01:03 +0000 |
commit | 30fc4309ed1e3ccf7d2e8d9d3401a485e1991375 (patch) | |
tree | 2d9a1740d6cb85db94ab30043ed81de573e27e10 /doio.c | |
parent | 98960e6aa96e8e7fc9582821b2697efb96583e4c (diff) | |
download | perl-30fc4309ed1e3ccf7d2e8d9d3401a485e1991375.tar.gz |
Re: [perl #60904] Race condition with perl -i.bk
Message-ID: <20081201230112.GH31089@tytlal.topaz.cx>
Use mode 0600 (minus umask) for creation of the new file with -i
p4raw-id: //depot/perl@35082
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -811,8 +811,7 @@ Perl_nextargv(pTHX_ register GV *gv) do_close(gv,FALSE); (void)PerlLIO_unlink(SvPVX_const(sv)); (void)PerlLIO_rename(PL_oldname,SvPVX_const(sv)); - do_open(gv,(char*)SvPVX_const(sv),SvCUR(sv),PL_inplace!=0, - O_RDONLY,0,NULL); + do_open(gv,(char*)SvPVX_const(sv),SvCUR(sv),TRUE,O_RDONLY,0,NULL); #endif /* DOSISH */ #else (void)UNLINK(SvPVX_const(sv)); @@ -844,17 +843,15 @@ Perl_nextargv(pTHX_ register GV *gv) #endif } - sv_setpvn(sv,">",!PL_inplace); - sv_catpvn(sv,PL_oldname,oldlen); + sv_setpvn(sv,PL_oldname,oldlen); SETERRNO(0,0); /* in case sprintf set errno */ + if (!do_open(PL_argvoutgv,(char*)SvPVX_const(sv),SvCUR(sv),TRUE, #ifdef VMS - if (!do_open(PL_argvoutgv,(char*)SvPVX_const(sv),SvCUR(sv), - PL_inplace!=0,O_WRONLY|O_CREAT|O_TRUNC,0,NULL)) + O_WRONLY|O_CREAT|O_TRUNC,0, #else - if (!do_open(PL_argvoutgv,(char*)SvPVX_const(sv),SvCUR(sv), - PL_inplace!=0,O_WRONLY|O_CREAT|OPEN_EXCL,0666, - NULL)) + O_WRONLY|O_CREAT|OPEN_EXCL,0600, #endif + NULL)) { if (ckWARN_d(WARN_INPLACE)) Perl_warner(aTHX_ packWARN(WARN_INPLACE), "Can't do inplace edit on %s: %s", |