This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: AW: umask handling in File::Temp
authorGisle Aas <gisle@aas.no>
Fri, 12 Jan 2007 16:10:16 +0000 (17:10 +0100)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sat, 13 Jan 2007 16:56:02 +0000 (16:56 +0000)
Message-ID:  <877ivs1dt3.fsf@ask.g.aas.no>

p4raw-id: //depot/perl@29784

pp_sys.c

index ca2a110..974f32a 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -707,8 +707,12 @@ PP(pp_umask)
     Mode_t anum;
 
     if (MAXARG < 1) {
-       anum = PerlLIO_umask(0);
-       (void)PerlLIO_umask(anum);
+       anum = PerlLIO_umask(022);
+       /* setting it to 022 between the two calls to umask avoids
+        * to have a window where the umask is set to 0 -- meaning
+        * that another thread could create world-writeable files. */
+       if (anum != 022)
+           (void)PerlLIO_umask(anum);
     }
     else
        anum = PerlLIO_umask(POPi);