Changeset 9830


Ignore:
Timestamp:
Dec 28, 2009, 12:35:29 AM (13 years ago)
Author:
charles
Message:

(trunk libT) https://bugs.launchpad.net/ubuntu/+source/transmission/+bug/500625

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/metainfo.c

    r9681 r9830  
    126126
    127127static tr_bool
    128 getfile( char        ** setme,
    129          const char   * root,
    130          tr_benc      * path )
     128path_is_suspicious( const char * path )
     129{
     130    return ( path == NULL )
     131        || ( strstr( path, "../" ) != NULL );
     132}
     133
     134static tr_bool
     135getfile( char ** setme, const char * root, tr_benc * path )
    131136{
    132137    tr_bool success = FALSE;
     
    134139    if( tr_bencIsList( path ) )
    135140    {
     141        int i;
     142        const int n = tr_bencListSize( path );
    136143        struct evbuffer * buf = evbuffer_new( );
    137         int               n = tr_bencListSize( path );
    138         int               i;
    139144
    140145        evbuffer_add( buf, root, strlen( root ) );
     
    142147        {
    143148            const char * str;
    144             if( tr_bencGetStr( tr_bencListChild( path, i ), &str )
    145               && strcmp( str, ".." ) )
     149            if( tr_bencGetStr( tr_bencListChild( path, i ), &str ) )
    146150            {
    147151                evbuffer_add( buf, TR_PATH_DELIMITER_STR, 1 );
     
    156160    }
    157161
     162    if( ( *setme != NULL ) && path_is_suspicious( *setme ) )
     163    {
     164        tr_free( *setme );
     165        *setme = NULL;
     166        success = FALSE;
     167    }
     168
    158169    return success;
    159170}
    160171
    161172static const char*
    162 parseFiles( tr_info *       inf,
    163             tr_benc *       files,
    164             const tr_benc * length )
     173parseFiles( tr_info * inf, tr_benc * files, const tr_benc * length )
    165174{
    166175    int64_t len;
     
    201210    else if( tr_bencGetInt( length, &len ) ) /* single-file mode */
    202211    {
     212        if( path_is_suspicious( inf->name ) )
     213            return "path";
     214
    203215        inf->isMultifile      = 0;
    204216        inf->fileCount        = 1;
Note: See TracChangeset for help on using the changeset viewer.