ref: a29dc4b3043206ce0df4a5de7eff59a3b545b0d4
parent: 6b290a954025a035ee4b3483563ec55bfa72131a
author: Diego Biurrun <diego@biurrun.de>
date: Mon Nov 10 09:19:44 EST 2014
libdvdcss: Ensure that path for cache directory tag does not exceed PATH_MAX
--- a/src/css.h
+++ b/src/css.h
@@ -32,7 +32,6 @@
#include "common.h"
#include "dvdcss/dvdcss.h"
-#define CACHE_FILENAME_LENGTH 10
#define CACHE_FILENAME_LENGTH_STRING "10"
#define DVD_KEY_SIZE 5
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -136,6 +136,7 @@
#define mkdir(a, b) _mkdir(a)
#endif
+#define CACHE_TAG_NAME "CACHEDIR.TAG"
#define STRING_KEY_SIZE (DVD_KEY_SIZE * 2)
#define INTERESTING_SECTOR 16
@@ -261,10 +262,10 @@
}
/* Check that there is enough space for the cache directory path and the
- * block filename. The +1 are path separators and terminating null byte. */
+ * block filename. The +1s are path separators. */
if( psz_cache && strlen( psz_cache ) + 1 + DISC_TITLE_LENGTH + 1 +
MANUFACTURING_DATE_LENGTH + 1 + STRING_KEY_SIZE + 1 +
- CACHE_FILENAME_LENGTH + 1 > PATH_MAX )
+ sizeof(CACHE_TAG_NAME) > PATH_MAX )
{
print_error( dvdcss, "cache directory name is too long" );
return NULL;
@@ -279,7 +280,7 @@
"# This file is a cache directory tag created by libdvdcss.\r\n"
"# For information about cache directory tags, see:\r\n"
"# http://www.brynosaurus.com/cachedir/\r\n";
- char psz_tagfile[PATH_MAX + 1 + 12 + 1];
+ char psz_tagfile[PATH_MAX];
int i_fd, i_ret;
i_ret = mkdir( psz_cache, 0755 );
@@ -290,7 +291,7 @@
return;
}
- sprintf( psz_tagfile, "%s/CACHEDIR.TAG", psz_cache );
+ sprintf( psz_tagfile, "%s/" CACHE_TAG_NAME, psz_cache );
i_fd = open( psz_tagfile, O_RDWR|O_CREAT, 0644 );
if( i_fd >= 0 )
{