Changeset 4323


Ignore:
Timestamp:
Dec 25, 2007, 1:23:07 AM (15 years ago)
Author:
charles
Message:

fix torrent parsing bug reported by m1b, SoftwareElves?, and BentMyWookie?

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/metainfo.c

    r4286 r4323  
    149149}
    150150
     151static void
     152savedname( char * name, size_t len, const char * hash, const char * tag )
     153{
     154    const char * torDir = tr_getTorrentsDirectory ();
     155
     156    if( tag == NULL )
     157    {
     158        tr_buildPath( name, len, torDir, hash, NULL );
     159    }
     160    else
     161    {
     162        char base[1024];
     163        snprintf( base, sizeof(base), "%s-%s", hash, tag );
     164        tr_buildPath( name, len, torDir, base, NULL );
     165    }
     166}
     167
     168
    151169int
    152 tr_metainfoParse( tr_info * inf, const benc_val_t * meta_in )
     170tr_metainfoParse( tr_info * inf, const benc_val_t * meta_in, const char * tag )
    153171{
    154172    int i;
     
    177195                  "%02x", inf->hash[i] );
    178196    }
     197    savedname( inf->torrent, sizeof( inf->torrent ), inf->hashString, tag );
    179198
    180199    /* Comment info */
     
    557576}
    558577
    559 
    560 static void
    561 savedname( char * name, size_t len, const char * hash, const char * tag )
    562 {
    563     const char * torDir = tr_getTorrentsDirectory ();
    564 
    565     if( tag == NULL )
    566     {
    567         tr_buildPath( name, len, torDir, hash, NULL );
    568     }
    569     else
    570     {
    571         char base[1024];
    572         snprintf( base, sizeof(base), "%s-%s", hash, tag );
    573         tr_buildPath( name, len, torDir, base, NULL );
    574     }
    575 }
    576 
    577 void tr_metainfoRemoveSaved( const char * hashString, const char * tag )
     578void
     579tr_metainfoRemoveSaved( const char * hashString, const char * tag )
    578580{
    579581    char file[MAX_PATH_LENGTH];
    580 
    581582    savedname( file, sizeof file, hashString, tag );
    582583    unlink( file );
  • trunk/libtransmission/metainfo.h

    r4286 r4323  
    3030struct benc_val_t;
    3131
    32 int tr_metainfoParse( tr_info *, const struct benc_val_s * );
     32int tr_metainfoParse( tr_info *, const struct benc_val_s *, const char * tag );
    3333void tr_metainfoFree( tr_info * inf );
    3434void tr_metainfoRemoveSaved( const char * hashString, const char * tag );
  • trunk/libtransmission/torrent.c

    r4306 r4323  
    417417        return TR_EINVALID;
    418418
    419     err = tr_metainfoParse( setmeInfo, metainfo );
     419    err = tr_metainfoParse( setmeInfo, metainfo, handle->tag );
    420420    doFree = !err && ( setmeInfo == &tmp );
    421421
Note: See TracChangeset for help on using the changeset viewer.