64 lines
2.1 KiB
Plaintext
64 lines
2.1 KiB
Plaintext
- sprintf -> strcpy
|
|
47a582c67029ce2c57e83112794a3e3f710b844b
|
|
- dvd_reader: Use realpath instead of chdir/getcwd
|
|
21e8964e71bbc743123c458a3f1a4ff544d1ed6b
|
|
|
|
Index: src/dvd_reader.c
|
|
--- src/dvd_reader.c.orig
|
|
+++ src/dvd_reader.c
|
|
@@ -29,7 +29,7 @@
|
|
#include <stdio.h> /* fprintf */
|
|
#include <errno.h> /* errno, EIN* */
|
|
#include <string.h> /* memcpy, strlen */
|
|
-#include <unistd.h> /* chdir, getcwd */
|
|
+#include <unistd.h> /* pclose */
|
|
#include <limits.h> /* PATH_MAX */
|
|
#include <dirent.h> /* opendir, readdir */
|
|
#include <ctype.h> /* isalpha */
|
|
@@ -286,7 +286,7 @@ static int initAllCSSKeys( dvd_reader_t *ctx )
|
|
for( title = 0; title < 100; title++ ) {
|
|
gettimeofday( &t_s, NULL );
|
|
if( title == 0 ) {
|
|
- sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
|
|
+ strcpy( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
|
|
} else {
|
|
sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 0 );
|
|
}
|
|
@@ -549,33 +549,18 @@ static dvd_reader_t *DVDOpenCommon( void *priv,
|
|
if( !(path_copy = strdup( path ) ) )
|
|
goto DVDOpen_error;
|
|
|
|
-#ifndef _WIN32 /* don't have fchdir, and getcwd( NULL, ... ) is strange */
|
|
+#ifndef _WIN32 /* win32 doesn't have realpath */
|
|
/* Also WIN32 does not have symlinks, so we don't need this bit of code. */
|
|
|
|
/* Resolve any symlinks and get the absolute dir name. */
|
|
{
|
|
- if( ( cdir = open( ".", O_RDONLY ) ) >= 0 ) {
|
|
- int retval;
|
|
- if( chdir( path_copy ) == -1 ) {
|
|
+ new_path = realpath( path_copy, NULL );
|
|
+ if( new_path == NULL ) {
|
|
goto DVDOpen_error;
|
|
}
|
|
- new_path = malloc(PATH_MAX+1);
|
|
- if(!new_path) {
|
|
- goto DVDOpen_error;
|
|
- }
|
|
- if( getcwd( new_path, PATH_MAX ) == NULL ) {
|
|
- goto DVDOpen_error;
|
|
- }
|
|
- retval = fchdir( cdir );
|
|
- close( cdir );
|
|
- cdir = -1;
|
|
- if( retval == -1 ) {
|
|
- goto DVDOpen_error;
|
|
- }
|
|
free(path_copy);
|
|
path_copy = new_path;
|
|
new_path = NULL;
|
|
- }
|
|
}
|
|
#endif
|
|
|