Mercurial > mplayer.hg
changeset 36253:5c8339df2496
Check if path is too long
Some buggy libc such as OS/2 kLIBC crashes if path is too long.
author | komh |
---|---|
date | Mon, 17 Jun 2013 12:27:36 +0000 |
parents | 2af48d236902 |
children | 74584d25e712 |
files | configure osdep/osdep.h stream/stream_file.c sub/subreader.c sub/vobsub.c |
diffstat | 5 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 <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
--- 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;
--- 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 <enca.h>
--- 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.