[MPlayer-cvslog] r36349 - in trunk: configure osdep/osdep.h stream/stream_file.c sub/subreader.c sub/vobsub.c

komh subversion at mplayerhq.hu
Mon Jun 17 14:27:37 CEST 2013


Author: komh
Date: Mon Jun 17 14:27:36 2013
New Revision: 36349

Log:
Check if path is too long

Some buggy libc such as OS/2 kLIBC crashes if path is too long.

Modified:
   trunk/configure
   trunk/osdep/osdep.h
   trunk/stream/stream_file.c
   trunk/sub/subreader.c
   trunk/sub/vobsub.c

Modified: trunk/configure
==============================================================================
--- trunk/configure	Mon Jun 17 00:35:51 2013	(r36348)
+++ trunk/configure	Mon Jun 17 14:27:36 2013	(r36349)
@@ -855,6 +855,7 @@ _stream_cache=yes
 _priority=no
 def_dos_paths="#define HAVE_DOS_PATHS 0"
 def_stream_cache="#define CONFIG_STREAM_CACHE 1"
+def_path_max_check="#define CONFIG_PATH_MAX_CHECK 0"
 def_priority="#undef CONFIG_PRIORITY"
 def_pthread_cache="#undef PTHREAD_CACHE"
 shmem=no
@@ -1780,6 +1781,7 @@ if os2 ; then
   _priority=yes
   def_dos_paths="#define HAVE_DOS_PATHS 1"
   def_priority="#define CONFIG_PRIORITY 1"
+  def_path_max_check="#define CONFIG_PATH_MAX_CHECK 1"
 fi
 
 if wine ; then
@@ -8723,6 +8725,7 @@ $def_macosx_bundle
 $def_macosx_finder
 $def_maemo
 $def_memalign_hack
+$def_path_max_check
 $def_priority
 $def_quicktime
 $def_restrict_keyword

Modified: trunk/osdep/osdep.h
==============================================================================
--- trunk/osdep/osdep.h	Mon Jun 17 00:35:51 2013	(r36348)
+++ trunk/osdep/osdep.h	Mon Jun 17 14:27:36 2013	(r36349)
@@ -23,6 +23,28 @@
 #ifndef MPLAYER_OSDEP_H
 #define MPLAYER_OSDEP_H
 
+#include "config.h"
+
+#if CONFIG_PATH_MAX_CHECK
+#include <stdio.h>      /* fopen()   */
+#include <dirent.h>     /* opendir() */
+#include <io.h>         /* open()    */
+#include <fcntl.h>      /* open()    */
+#include <string.h>     /* strlen()  */
+#include <limits.h>     /* PATH_MAX  */
+#include <errno.h>      /* errno     */
+
+#define fopen(n, m) \
+    (strlen(n) >= PATH_MAX ? (errno = ENAMETOOLONG, NULL) : (fopen)(n, m))
+
+#define opendir(n) \
+    (strlen(n) >= PATH_MAX ? (errno = ENOENT, NULL) : (opendir)(n))
+
+#define open(n, ...) \
+    (strlen(n) >= PATH_MAX ? (errno = ENAMETOOLONG, -1) : \
+                             (open)(n, __VA_ARGS__))
+#endif /* CONFIG_PATH_MAX_CHECK */
+
 #ifdef __OS2__
 #define INCL_DOS
 #define INCL_DOSDEVIOCTL

Modified: trunk/stream/stream_file.c
==============================================================================
--- trunk/stream/stream_file.c	Mon Jun 17 00:35:51 2013	(r36348)
+++ trunk/stream/stream_file.c	Mon Jun 17 14:27:36 2013	(r36349)
@@ -36,6 +36,7 @@
 #include "help_mp.h"
 #include "m_option.h"
 #include "m_struct.h"
+#include "osdep/osdep.h"
 
 static struct stream_priv_s {
   char* filename;

Modified: trunk/sub/subreader.c
==============================================================================
--- trunk/sub/subreader.c	Mon Jun 17 00:35:51 2013	(r36348)
+++ trunk/sub/subreader.c	Mon Jun 17 14:27:36 2013	(r36349)
@@ -42,6 +42,7 @@
 #include "stream/stream.h"
 #include "libavutil/common.h"
 #include "libavutil/avstring.h"
+#include "osdep/osdep.h"
 
 #ifdef CONFIG_ENCA
 #include <enca.h>

Modified: trunk/sub/vobsub.c
==============================================================================
--- trunk/sub/vobsub.c	Mon Jun 17 00:35:51 2013	(r36348)
+++ trunk/sub/vobsub.c	Mon Jun 17 14:27:36 2013	(r36349)
@@ -42,6 +42,7 @@
 #include "unrar_exec.h"
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
+#include "osdep/osdep.h"
 
 // Record the original -vobsubid set by commandline, since vobsub_id will be
 // overridden if slang match any of vobsub streams.


More information about the MPlayer-cvslog mailing list