mirror of
https://github.com/transmission/transmission
synced 2025-02-21 13:46:52 +00:00
This commit is contained in:
parent
c242a19eaf
commit
4e44e9c2cb
1 changed files with 22 additions and 10 deletions
|
@ -125,24 +125,28 @@ tr_metainfoMigrate( tr_session * session,
|
||||||
***/
|
***/
|
||||||
|
|
||||||
static tr_bool
|
static tr_bool
|
||||||
getfile( char ** setme,
|
path_is_suspicious( const char * path )
|
||||||
const char * root,
|
{
|
||||||
tr_benc * path )
|
return ( path == NULL )
|
||||||
|
|| ( strstr( path, "../" ) != NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
static tr_bool
|
||||||
|
getfile( char ** setme, const char * root, tr_benc * path )
|
||||||
{
|
{
|
||||||
tr_bool success = FALSE;
|
tr_bool success = FALSE;
|
||||||
|
|
||||||
if( tr_bencIsList( path ) )
|
if( tr_bencIsList( path ) )
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
const int n = tr_bencListSize( path );
|
||||||
struct evbuffer * buf = evbuffer_new( );
|
struct evbuffer * buf = evbuffer_new( );
|
||||||
int n = tr_bencListSize( path );
|
|
||||||
int i;
|
|
||||||
|
|
||||||
evbuffer_add( buf, root, strlen( root ) );
|
evbuffer_add( buf, root, strlen( root ) );
|
||||||
for( i = 0; i < n; ++i )
|
for( i = 0; i < n; ++i )
|
||||||
{
|
{
|
||||||
const char * str;
|
const char * str;
|
||||||
if( tr_bencGetStr( tr_bencListChild( path, i ), &str )
|
if( tr_bencGetStr( tr_bencListChild( path, i ), &str ) )
|
||||||
&& strcmp( str, ".." ) )
|
|
||||||
{
|
{
|
||||||
evbuffer_add( buf, TR_PATH_DELIMITER_STR, 1 );
|
evbuffer_add( buf, TR_PATH_DELIMITER_STR, 1 );
|
||||||
evbuffer_add( buf, str, strlen( str ) );
|
evbuffer_add( buf, str, strlen( str ) );
|
||||||
|
@ -155,13 +159,18 @@ getfile( char ** setme,
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( ( *setme != NULL ) && path_is_suspicious( *setme ) )
|
||||||
|
{
|
||||||
|
tr_free( *setme );
|
||||||
|
*setme = NULL;
|
||||||
|
success = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
parseFiles( tr_info * inf,
|
parseFiles( tr_info * inf, tr_benc * files, const tr_benc * length )
|
||||||
tr_benc * files,
|
|
||||||
const tr_benc * length )
|
|
||||||
{
|
{
|
||||||
int64_t len;
|
int64_t len;
|
||||||
|
|
||||||
|
@ -200,6 +209,9 @@ parseFiles( tr_info * inf,
|
||||||
}
|
}
|
||||||
else if( tr_bencGetInt( length, &len ) ) /* single-file mode */
|
else if( tr_bencGetInt( length, &len ) ) /* single-file mode */
|
||||||
{
|
{
|
||||||
|
if( path_is_suspicious( inf->name ) )
|
||||||
|
return "path";
|
||||||
|
|
||||||
inf->isMultifile = 0;
|
inf->isMultifile = 0;
|
||||||
inf->fileCount = 1;
|
inf->fileCount = 1;
|
||||||
inf->files = tr_new0( tr_file, 1 );
|
inf->files = tr_new0( tr_file, 1 );
|
||||||
|
|
Loading…
Reference in a new issue