Browse code

av_tempfile: use O_EXCL

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/10/17 04:25:07
Showing 1 changed files
... ...
@@ -152,7 +152,10 @@ int av_tempfile(const char *prefix, char **filename) {
152 152
 #   ifndef O_BINARY
153 153
 #       define O_BINARY 0
154 154
 #   endif
155
-    fd = open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444);
155
+#   ifndef O_EXCL
156
+#       define O_EXCL 0
157
+#   endif
158
+    fd = open(*filename, O_RDWR | O_BINARY | O_CREAT | O_EXCL, 0444);
156 159
 #else
157 160
     snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
158 161
     fd = mkstemp(*filename);