aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2016-08-08 15:27:41 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-08-23 13:15:16 +0200
commitaa54f0926273a7142195e01ec01fa99f1c903613 (patch)
tree36f34e539424dff9b446123088928ca5056959e9
parent9a3d09e2c935dc8dd22abc27f313a68d43ef2bbc (diff)
downloadffmpeg-aa54f0926273a7142195e01ec01fa99f1c903613.tar.gz
cmdutils: remove the current working directory from the DLL search path on win32
Reviewed-by: Matt Oliver <protogonoi@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 3bf142c77337814458ed8e036796934032d9837f) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--cmdutils.c9
-rw-r--r--cmdutils.h5
-rw-r--r--ffmpeg.c2
-rw-r--r--ffplay.c2
-rw-r--r--ffprobe.c2
-rw-r--r--ffserver.c2
6 files changed, 22 insertions, 0 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 612810a374..01bc82ce98 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -111,6 +111,15 @@ static void log_callback_report(void *ptr, int level, const char *fmt, va_list v
}
}
+void init_dynload(void)
+{
+#ifdef _WIN32
+ /* Calling SetDllDirectory with the empty string (but not NULL) removes the
+ * current working directory from the DLL search path as a security pre-caution. */
+ SetDllDirectory("");
+#endif
+}
+
static void (*program_exit)(int ret);
void register_exit(void (*cb)(int ret))
diff --git a/cmdutils.h b/cmdutils.h
index 76d11a598c..3bd778b94b 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -62,6 +62,11 @@ void register_exit(void (*cb)(int ret));
void exit_program(int ret) av_noreturn;
/**
+ * Initialize dynamic library loading
+ */
+void init_dynload(void);
+
+/**
* Initialize the cmdutils option system, in particular
* allocate the *_opts contexts.
*/
diff --git a/ffmpeg.c b/ffmpeg.c
index e676414f4b..efd890355e 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3822,6 +3822,8 @@ int main(int argc, char **argv)
int ret;
int64_t ti;
+ init_dynload();
+
register_exit(ffmpeg_cleanup);
setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
diff --git a/ffplay.c b/ffplay.c
index 833b5b12cf..be7bd2e93b 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3659,6 +3659,8 @@ int main(int argc, char **argv)
VideoState *is;
char dummy_videodriver[] = "SDL_VIDEODRIVER=dummy";
+ init_dynload();
+
av_log_set_flags(AV_LOG_SKIP_REPEATED);
parse_loglevel(argc, argv, options);
diff --git a/ffprobe.c b/ffprobe.c
index 9bb0f0f10c..fecbbce5d8 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -2962,6 +2962,8 @@ int main(int argc, char **argv)
char *w_name = NULL, *w_args = NULL;
int ret, i;
+ init_dynload();
+
av_log_set_flags(AV_LOG_SKIP_REPEATED);
register_exit(ffprobe_cleanup);
diff --git a/ffserver.c b/ffserver.c
index 24e400504c..ff33b2f263 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -4724,6 +4724,8 @@ int main(int argc, char **argv)
struct sigaction sigact = { { 0 } };
int ret = 0;
+ init_dynload();
+
config_filename = av_strdup("/etc/ffserver.conf");
parse_loglevel(argc, argv, options);