# HG changeset patch # User komh # Date 1371472056 0 # Node ID 5c8339df2496fea06f8ba313152776a1e2a3ab6e # Parent 2af48d236902df519c19b5d324b1fba01007273d Check if path is too long Some buggy libc such as OS/2 kLIBC crashes if path is too long. diff -r 2af48d236902 -r 5c8339df2496 configure --- a/configure Sun Jun 16 22:35:51 2013 +0000 +++ b/configure Mon Jun 17 12:27:36 2013 +0000 @@ -855,6 +855,7 @@ _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 @@ _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_finder $def_maemo $def_memalign_hack +$def_path_max_check $def_priority $def_quicktime $def_restrict_keyword diff -r 2af48d236902 -r 5c8339df2496 osdep/osdep.h --- a/osdep/osdep.h Sun Jun 16 22:35:51 2013 +0000 +++ b/osdep/osdep.h Mon Jun 17 12:27:36 2013 +0000 @@ -23,6 +23,28 @@ #ifndef MPLAYER_OSDEP_H #define MPLAYER_OSDEP_H +#include "config.h" + +#if CONFIG_PATH_MAX_CHECK +#include /* fopen() */ +#include /* opendir() */ +#include /* open() */ +#include /* open() */ +#include /* strlen() */ +#include /* PATH_MAX */ +#include /* 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 diff -r 2af48d236902 -r 5c8339df2496 stream/stream_file.c --- a/stream/stream_file.c Sun Jun 16 22:35:51 2013 +0000 +++ b/stream/stream_file.c Mon Jun 17 12:27:36 2013 +0000 @@ -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; diff -r 2af48d236902 -r 5c8339df2496 sub/subreader.c --- a/sub/subreader.c Sun Jun 16 22:35:51 2013 +0000 +++ b/sub/subreader.c Mon Jun 17 12:27:36 2013 +0000 @@ -42,6 +42,7 @@ #include "stream/stream.h" #include "libavutil/common.h" #include "libavutil/avstring.h" +#include "osdep/osdep.h" #ifdef CONFIG_ENCA #include diff -r 2af48d236902 -r 5c8339df2496 sub/vobsub.c --- a/sub/vobsub.c Sun Jun 16 22:35:51 2013 +0000 +++ b/sub/vobsub.c Mon Jun 17 12:27:36 2013 +0000 @@ -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.