Changeset 2511


Ignore:
Timestamp:
Jul 27, 2007, 1:50:26 AM (15 years ago)
Author:
charles
Message:

gracefully fail when poison torrents containing no files, or zero byte files, are opened.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/metainfo.c

    r2494 r2511  
    254254    }
    255255
    256     /* TODO add more tests so we don't crash on weird files */
    257 
    258256    /* get file or top directory name */
    259257    val = tr_bencDictFindFirst( beInfo, "name.utf-8", "name", NULL );
     
    265263        goto fail;
    266264    }
     265
     266    if( !inf->fileCount )
     267    {
     268        tr_err( "Torrent has no files." );
     269        goto fail;
     270    }
     271    for( i=0; i<inf->fileCount; ++i )
     272    {
     273        if( !inf->files[i].length )
     274        {
     275            tr_err("File #%d, \"%s\" is zero bytes long.", (i+1), inf->files[i].name );
     276            goto fail;
     277        }
     278    }
     279
     280    /* TODO add more tests so we don't crash on weird files */
    267281
    268282    if( (uint64_t) inf->pieceCount !=
Note: See TracChangeset for help on using the changeset viewer.