Changeset 12324


Ignore:
Timestamp:
Apr 5, 2011, 10:21:18 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) fix ABR error when parsing a URL with no path and no trailing slash after the host. Error reported by livings124

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils-test.c

    r12248 r12324  
    386386    const char * url;
    387387
     388    url = "http://1";
     389    check( !tr_urlParse( url, -1, &scheme, &host, &port, &path ) );
     390    check( !strcmp( scheme, "http" ) )
     391    check( !strcmp( host, "1" ) )
     392    check( !strcmp( path, "/" ) )
     393    check( port == 80 )
     394    tr_free( scheme );
     395    tr_free( path );
     396    tr_free( host );
     397
    388398    url = "http://www.some-tracker.org/some/path";
    389399    check( !tr_urlParse( url, -1, &scheme, &host, &port, &path ) )
  • trunk/libtransmission/utils.c

    r12312 r12324  
    10311031            host_len = n;
    10321032            pch += n;
    1033             *pch++ = '\0';
     1033            if( pch && *pch )
     1034                *pch++ = '\0';
    10341035/*fprintf( stderr, "host is [%s]... what's left is [%s]\n", host, pch );*/
    10351036            if( havePort )
     
    10621063        if( setme_host ){ ( (char*)host )[-3] = ':'; *setme_host =
    10631064                              tr_strndup( host, host_len ); }
    1064         if( setme_path ){ if( path[0] == '/' ) *setme_path = tr_strdup( path );
     1065        if( setme_path ){ if( !*path ) *setme_path = tr_strdup( "/" );
     1066                          else if( path[0] == '/' ) *setme_path = tr_strdup( path );
    10651067                          else { ( (char*)path )[-1] = '/'; *setme_path = tr_strdup( path - 1 ); } }
    10661068        if( setme_port ) *setme_port = port;
Note: See TracChangeset for help on using the changeset viewer.