[FFmpeg-devel] [PATCH] wrap mkstemp with umask

Reimar Döffinger Reimar.Doeffinger
Thu Jul 17 21:39:33 CEST 2008


Hello,
On Thu, Jul 17, 2008 at 12:28:45PM -0700, Erik Hovland wrote:
> It is possible that the current umask of the process creating the file
> with mkstemp is such that the temp file could be writable by others then
> the user. When mkstemp is used it can be wrapped with umask() calls to
> make absolutely sure that the temp file cannot be tampered with.

That makes it completely thread-unsafe.
Since in the long time since this was last discussed and nobody bothered
to do anything about it I am in favour of throwing out this code and its
only user the libxvid 2-pass encoding along with it.
I've had this in my local tree since ages, though done the ugly way:

Index: libxvid_rc.c
===================================================================
--- libxvid_rc.c        (revision 14263)
+++ libxvid_rc.c        (working copy)
@@ -40,7 +40,7 @@
 
 //xvid_debug=-1;
 
-    fd=av_tempfile("xvidrc.", &tmp_name);
+    fd = -1;
     if (fd == -1) {
         av_log(NULL, AV_LOG_ERROR, "Can't create temporary pass2
file.\n");
         return -1;
Index: libxvidff.c
===================================================================
--- libxvidff.c (revision 14263)
+++ libxvidff.c (working copy)
@@ -231,7 +231,7 @@
         rc2pass2.version = XVID_VERSION;
         rc2pass2.bitrate = avctx->bit_rate;
 
-        fd = av_tempfile("xvidff.", &(x->twopassfile));
+        fd = -1;
         if( fd == -1 ) {
             av_log(avctx, AV_LOG_ERROR,
                 "Xvid: Cannot write 2-pass pipe\n");


Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list