diff options
author | Diego Biurrun <diego@biurrun.de> | 2015-02-12 10:11:22 +0100 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2016-11-11 10:17:07 +0100 |
commit | 12db2832e41aa71b5903ef7fa5c59c5473ded2c5 (patch) | |
tree | 15d203def7435e1fbbc513b6c339bee0988d141e /libavcodec/libxvid_rc.c | |
parent | a67ae67083151f2f9595a1f2d17b601da19b939e (diff) | |
download | ffmpeg-12db2832e41aa71b5903ef7fa5c59c5473ded2c5.tar.gz |
libxvid: Require availability of mkstemp()
The replacement code uses tempnam(), which is dangerous.
Such a fringe feature is not worth the trouble.
Diffstat (limited to 'libavcodec/libxvid_rc.c')
-rw-r--r-- | libavcodec/libxvid_rc.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c index 26f3c495c1..91302832e0 100644 --- a/libavcodec/libxvid_rc.c +++ b/libavcodec/libxvid_rc.c @@ -22,9 +22,7 @@ #include "config.h" -#if !HAVE_MKSTEMP #include <fcntl.h> -#endif #include <unistd.h> #include <xvid.h> @@ -35,36 +33,25 @@ #include "libxvid.h" #include "mpegvideo.h" -/* Wrapper to work around the lack of mkstemp() on mingw. - * Also, tries to create file in /tmp first, if possible. +/* Create temporary file using mkstemp(), tries /tmp first, if possible. * *prefix can be a character constant; *filename will be allocated internally. - * @return file descriptor of opened file (or -1 on error) + * Return file descriptor of opened file (or error code on error) * and opened file name in **filename. */ int ff_tempfile(const char *prefix, char **filename) { int fd = -1; -#if !HAVE_MKSTEMP - *filename = tempnam(".", prefix); -#else size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */ *filename = av_malloc(len); -#endif - /* -----common section-----*/ if (!(*filename)) { av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n"); return AVERROR(ENOMEM); } -#if !HAVE_MKSTEMP - fd = avpriv_open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444); -#else snprintf(*filename, len, "/tmp/%sXXXXXX", prefix); fd = mkstemp(*filename); if (fd < 0) { snprintf(*filename, len, "./%sXXXXXX", prefix); fd = mkstemp(*filename); } -#endif - /* -----common section-----*/ if (fd < 0) { av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename); return AVERROR(EIO); |