[FFmpeg-devel] stlport with ffmpeg: Issue with time_is_forbidden_due_to_security_issues

Carl Eugen Hoyos cehoyos at ag.or.at
Thu Sep 13 00:28:57 CEST 2012


On Thursday 13 September 2012 12:13:44 am Reimar Döffinger wrote:
> On 12 Sep 2012, at 21:02, Raymond Toy <rtoy at google.com> wrote:
> > I'm currently building ffmpeg on Android and it pretty much works, but
> > I've run into a problem with ffmpeg's time and stlport.
> >
> > In internal.h, ffmpeg has
> >
> > #undef time
> > #define time time_is_forbidden_due_to_security_issues
> >
> > In various ffmpeg files, there is
> >
> > #include <time.h>
> >
> > When building ffmpeg on my Android system, the stlport version of time.h,
> > which basically does something like
> >
> > #define _STLP_NATIVE_C_HEADER(header) <../include/header>
> > #include _STLP_NATIVE_C_HEADER(time.h)
> >
> > Because of the #define in internal.h  this gets expanded as
> >
> > #include <../include/time_is_forbidden_due_to_security_issues.h>
> >
> > That file, of course, doesn't exist.  I assume the intent of the #undef
> > and #define is to prevent uses of the function time, not to prevent
> > including <time.h>. I'm currently getting around this be removing the
> > #define from internal.h so that I can continue my development, but that
> > is not the right solution.
> >
> > Any suggestions on how to solve this?
> 
> System headers should be included before FFmpeg headers for exactly this
>  reason (with the exception of config.h, which we need to figure out
>  whether we can include certain system headers, but should not cause that
>  kind of issue).

Untested patch attached.

Carl Eugen
-------------- next part --------------
diff --git a/ffmpeg.c b/ffmpeg.c
index 4d12f80..2110a9e 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -38,6 +38,8 @@
 #include <unistd.h>
 #endif
 #endif
+#include <time.h>
+
 #include "libavformat/avformat.h"
 #include "libavdevice/avdevice.h"
 #include "libswscale/swscale.h"
@@ -96,8 +98,6 @@
 #include <pthread.h>
 #endif
 
-#include <time.h>
-
 #include "ffmpeg.h"
 #include "cmdutils.h"
 
diff --git a/ffserver.c b/ffserver.c
index c1c247b..6ef22c1 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -29,6 +29,7 @@
 #endif
 #include <string.h>
 #include <stdlib.h>
+#include <time.h>
 #include "libavformat/avformat.h"
 // FIXME those are internal headers, ffserver _really_ shouldn't use them
 #include "libavformat/ffm.h"
@@ -58,7 +59,6 @@
 #include <poll.h>
 #endif
 #include <errno.h>
-#include <time.h>
 #include <sys/wait.h>
 #include <signal.h>
 #if HAVE_DLFCN_H
diff --git a/libavdevice/v4l.c b/libavdevice/v4l.c
index 3d75110..e048336 100644
--- a/libavdevice/v4l.c
+++ b/libavdevice/v4l.c
@@ -23,12 +23,6 @@
 
 #undef __STRICT_ANSI__ //workaround due to broken kernel headers
 #include "config.h"
-#include "libavutil/rational.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/log.h"
-#include "libavutil/opt.h"
-#include "libavformat/internal.h"
-#include "libavcodec/dsputil.h"
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
@@ -37,6 +31,12 @@
 #define _LINUX_TIME_H 1
 #include <linux/videodev.h>
 #include <time.h>
+#include "libavutil/rational.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
+#include "libavformat/internal.h"
+#include "libavcodec/dsputil.h"
 #include "avdevice.h"
 
 typedef struct {
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index b6bd486..27e7a8c 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -37,12 +37,12 @@
  */
 
 #include "config.h"
+#include <time.h>
 #include "libavformat/internal.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
 #include "libavutil/parseutils.h"
 #include "libavutil/time.h"
-#include <time.h>
 #include <X11/X.h>
 #include <X11/Xlib.h>
 #include <X11/Xlibint.h>


More information about the ffmpeg-devel mailing list