OSDN Git Service

av_tempfile: use O_EXCL
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 16 Oct 2011 19:25:07 +0000 (21:25 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 16 Oct 2011 19:51:28 +0000 (21:51 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavutil/file.c

index 44d2ca4..e73e8ef 100644 (file)
@@ -152,7 +152,10 @@ int av_tempfile(const char *prefix, char **filename) {
 #   ifndef O_BINARY
 #       define O_BINARY 0
 #   endif
-    fd = open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444);
+#   ifndef O_EXCL
+#       define O_EXCL 0
+#   endif
+    fd = open(*filename, O_RDWR | O_BINARY | O_CREAT | O_EXCL, 0444);
 #else
     snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
     fd = mkstemp(*filename);