Changeset 9274


Ignore:
Timestamp:
Oct 10, 2009, 7:16:21 PM (13 years ago)
Author:
charles
Message:

(trunk libT) #2489: tr_torrentSetAnnounceList() should check for invalid and duplicate announce URLs

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r9251 r9274  
    20122012***/
    20132013
    2014 void
     2014tr_announce_list_err
    20152015tr_torrentSetAnnounceList( tr_torrent *            tor,
    20162016                           const tr_tracker_info * trackers,
    20172017                           int                     trackerCount )
    20182018{
     2019    int i, j;
    20192020    tr_benc metainfo;
    20202021
    20212022    assert( tr_isTorrent( tor ) );
     2023
     2024    /* look for bad URLs */
     2025    for( i=0; i<trackerCount; ++i )
     2026        if( !tr_httpIsValidURL( trackers[i].announce ) )
     2027            return TR_ANNOUNCE_LIST_HAS_BAD;
     2028
     2029    /* look for duplicates */
     2030    for( i=0; i<trackerCount; ++i )
     2031        for( j=0; j<trackerCount; ++j )
     2032            if(    ( i != j )
     2033                && ( trackers[i].tier == trackers[j].tier)
     2034                && ( !strcmp( trackers[i].announce, trackers[j].announce ) ) )
     2035                    return TR_ANNOUNCE_LIST_HAS_DUPLICATES;
    20222036
    20232037    /* save to the .torrent file */
     
    20692083        tr_announcerResetTorrent( tor->session->announcer, tor );
    20702084    }
     2085
     2086    return TR_ANNOUNCE_LIST_OK;
    20712087}
    20722088
  • trunk/libtransmission/transmission.h

    r9259 r9274  
    11021102tr_tracker_info;
    11031103
     1104
     1105typedef enum
     1106{
     1107  TR_ANNOUNCE_LIST_OK,
     1108  TR_ANNOUNCE_LIST_HAS_DUPLICATES,
     1109  TR_ANNOUNCE_LIST_HAS_BAD
     1110}
     1111tr_announce_list_err;
     1112
    11041113/**
    11051114 * @brief Modify a torrent's tracker list.
     
    11141123 * @param trackerCount size of the `trackers' array
    11151124 */
    1116 void tr_torrentSetAnnounceList( tr_torrent *            torrent,
    1117                                 const tr_tracker_info * trackers,
    1118                                 int                     trackerCount );
     1125tr_announce_list_err
     1126tr_torrentSetAnnounceList( tr_torrent             * torrent,
     1127                           const tr_tracker_info  * trackers,
     1128                           int                      trackerCount );
    11191129
    11201130
Note: See TracChangeset for help on using the changeset viewer.