(trunk libT) add some new bugs to the code so that it will crash when vraa tries to use it

This commit is contained in:
Charles Kerr 2010-11-11 15:31:11 +00:00
parent fafc36f78e
commit 9335e02e6d
11 changed files with 32 additions and 34 deletions

View File

@ -348,8 +348,8 @@ _tr_blocklistSetContent( tr_blocklist * b,
++inCount;
/* zap the linefeed */
if(( walk = strchr( line, '\r' ))) *walk = '\0';
if(( walk = strchr( line, '\n' ))) *walk = '\0';
if(( walk = strchr( line, '\r' ))) *walk = '\0';
if(( walk = strchr( line, '\n' ))) *walk = '\0';
if( !parseLine( line, &range ) )
{

View File

@ -303,7 +303,7 @@ cache_block_compare( const void * va, const void * vb )
static struct cache_block *
findBlock( tr_cache * cache,
tr_torrent * torrent,
tr_torrent * torrent,
tr_piece_index_t piece,
uint32_t offset )
{

View File

@ -399,7 +399,7 @@ TrOpenFile( tr_session * session,
}
#endif
#if defined( SYS_DARWIN )
#if defined( SYS_DARWIN )
/**
* 1. Enable readahead for reasons described above w/POSIX_FADV_SEQUENTIAL.
*
@ -411,8 +411,8 @@ TrOpenFile( tr_session * session,
*/
{
const int err = errno;
fcntl( file->fd, F_NOCACHE, 1 );
fcntl( file->fd, F_RDAHEAD, 1 );
fcntl( file->fd, F_NOCACHE, 1 );
fcntl( file->fd, F_RDAHEAD, 1 );
errno = err;
}
#endif

View File

@ -42,7 +42,7 @@ tr_metainfoGetBasename( const tr_info * inf )
for( pch=name; pch && *pch; ++pch )
if( *pch == '/' )
*pch = '_';
ret = tr_strdup_printf( "%s.%16.16s", name, inf->hashString );
tr_free( name );
@ -447,7 +447,6 @@ tr_metainfoParseImpl( const tr_session * session,
escape( inf->hashEscaped, inf->hash, SHA_DIGEST_LENGTH );
/* maybe get the display name */
if( tr_bencDictFindStr( d, "display-name", &str ) ) {
tr_free( inf->name );
inf->name = tr_strdup( str );

View File

@ -260,7 +260,7 @@ event_read_cb( int fd, short event UNUSED, void * vio )
what |= EVBUFFER_ERROR;
}
tr_net_strerror( errstr, sizeof( errstr ), e );
tr_net_strerror( errstr, sizeof( errstr ), e );
dbgmsg( io, "event_read_cb got an error. res is %d, what is %hd, errno is %d (%s)", res, what, e, errstr );
if( io->gotError != NULL )
@ -400,7 +400,7 @@ tr_peerIoNew( tr_session * session,
tr_netSetTOS( socket, session->peerSocketTOS );
maybeSetCongestionAlgorithm( socket, session->peer_congestion_algorithm );
}
io = tr_new0( tr_peerIo, 1 );
io->magicNumber = MAGIC_NUMBER;
io->refCount = 1;
@ -945,7 +945,7 @@ tr_peerIoTryRead( tr_peerIo * io, size_t howmuch )
short what = EVBUFFER_READ | EVBUFFER_ERROR;
if( res == 0 )
what |= EVBUFFER_EOF;
tr_net_strerror( errstr, sizeof( errstr ), e );
tr_net_strerror( errstr, sizeof( errstr ), e );
dbgmsg( io, "tr_peerIoTryRead got an error. res is %d, what is %hd, errno is %d (%s)", res, what, e, errstr );
io->gotError( io, what, io->userData );
}
@ -974,7 +974,7 @@ tr_peerIoTryWrite( tr_peerIo * io, size_t howmuch )
char errstr[512];
const short what = EVBUFFER_WRITE | EVBUFFER_ERROR;
tr_net_strerror( errstr, sizeof( errstr ), e );
tr_net_strerror( errstr, sizeof( errstr ), e );
dbgmsg( io, "tr_peerIoTryWrite got an error. res is %d, what is %hd, errno is %d (%s)", n, what, e, errstr );
if( io->gotError != NULL )

View File

@ -216,4 +216,3 @@ tr_ptrArrayRemoveSorted( tr_ptrArray * t,
assertSortedAndUnique( t, compare );
return ret;
}

View File

@ -386,7 +386,7 @@ add_response( struct evhttp_request * req,
EVBUFFER_LENGTH( out ) = content_len - server->stream.avail_out;
#if 0
fprintf( stderr, "compressed response is %.2f of original (raw==%zu bytes; compressed==%zu)\n",
fprintf( stderr, "compressed response is %.2f of original (raw==%zu bytes; compressed==%zu)\n",
(double)EVBUFFER_LENGTH(out)/content_len,
content_len, EVBUFFER_LENGTH(out) );
#endif

View File

@ -786,8 +786,8 @@ copyTrackers( tr_tracker_info * tgt, const tr_tracker_info * src, int n )
{
int i;
int maxTier = -1;
for( i=0; i<n; ++i )
for( i=0; i<n; ++i )
{
tgt[i].tier = src[i].tier;
tgt[i].announce = tr_strdup( src[i].announce );

View File

@ -451,7 +451,7 @@ tr_strip_positional_args( const char* str )
if( ( *str == '%' ) && ( str[1] == '\'' ) )
str = str + 1;
}
*out = '\0';
@ -1222,7 +1222,7 @@ strip_non_utf8( const char * in, size_t inlen )
const char * end;
const char zero = '\0';
struct evbuffer * buf = evbuffer_new( );
while( !tr_utf8_validate( in, inlen, &end ) )
{
const int good_len = end - in;
@ -1232,7 +1232,7 @@ strip_non_utf8( const char * in, size_t inlen )
in += ( good_len + 1 );
evbuffer_add( buf, "?", 1 );
}
evbuffer_add( buf, in, inlen );
evbuffer_add( buf, &zero, 1 );
ret = tr_memdup( EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ) );
@ -1437,8 +1437,8 @@ tr_truncd( double x, int precision )
{
char * pt;
char buf[128];
const int max_precision = (int) log10( 1.0 / DBL_EPSILON ) - 1;
tr_snprintf( buf, sizeof( buf ), "%.*f", max_precision, x );
const int max_precision = (int) log10( 1.0 / DBL_EPSILON ) - 1;
tr_snprintf( buf, sizeof( buf ), "%.*f", max_precision, x );
if(( pt = strstr( buf, localeconv()->decimal_point )))
pt[precision ? precision+1 : 0] = '\0';
return atof(buf);
@ -1608,7 +1608,7 @@ struct formatter_unit
char * name;
uint64_t value;
};
struct formatter_units
{
struct formatter_unit units[4];
@ -1720,7 +1720,7 @@ tr_formatter_speed_KBps( char * buf, double KBps, size_t buflen )
static struct formatter_units mem_units;
unsigned int tr_mem_K = 0u;
void
tr_formatter_mem_init( unsigned int kilo,
const char * kb, const char * mb,

View File

@ -272,11 +272,11 @@ getCurrentSize( tr_torrent * tor )
return byte_count;
}
static int
compareVerifyByPriorityAndSize( const void * va, const void * vb )
{
const struct verify_node * a = va;
const struct verify_node * b = vb;
static int
compareVerifyByPriorityAndSize( const void * va, const void * vb )
{
const struct verify_node * a = va;
const struct verify_node * b = vb;
/* higher priority comes before lower priority */
const tr_priority_t pa = tr_torrentGetPriority( a->torrent );
@ -288,7 +288,7 @@ compareVerifyByPriorityAndSize( const void * va, const void * vb )
if( a->current_size < b->current_size ) return -1;
if( a->current_size > b->current_size ) return 1;
return 0;
}
}
void
tr_verifyAdd( tr_torrent * tor,

View File

@ -144,10 +144,10 @@ createEasy( tr_session * s, struct tr_web_task * task )
const tr_address * addr;
CURL * e = curl_easy_init( );
const long verbose = getenv( "TR_CURL_VERBOSE" ) != NULL;
char * cookie_filename = tr_buildPath( s->configDir, "cookies.txt", NULL );
char * cookie_filename = tr_buildPath( s->configDir, "cookies.txt", NULL );
curl_easy_setopt( e, CURLOPT_AUTOREFERER, 1L );
curl_easy_setopt( e, CURLOPT_COOKIEFILE, cookie_filename );
curl_easy_setopt( e, CURLOPT_COOKIEFILE, cookie_filename );
curl_easy_setopt( e, CURLOPT_ENCODING, "gzip;q=1.0, deflate, identity" );
curl_easy_setopt( e, CURLOPT_FOLLOWLOCATION, 1L );
curl_easy_setopt( e, CURLOPT_MAXREDIRS, -1L );
@ -172,7 +172,7 @@ createEasy( tr_session * s, struct tr_web_task * task )
if( task->range )
curl_easy_setopt( e, CURLOPT_RANGE, task->range );
tr_free( cookie_filename );
tr_free( cookie_filename );
return e;
}
@ -232,7 +232,7 @@ tr_webRun( tr_session * session,
* http://msdn.microsoft.com/en-us/library/ms740141%28VS.85%29.aspx
* On win32, any two of the parameters, readfds, writefds, or exceptfds,
* can be given as null. At least one must be non-null, and any non-null
* descriptor set must contain at least one handle to a socket.
* descriptor set must contain at least one handle to a socket.
*/
static void
tr_select( int nfds,
@ -252,7 +252,7 @@ tr_select( int nfds,
char errstr[512];
const int e = EVUTIL_SOCKET_ERROR( );
tr_net_strerror( errstr, sizeof( errstr ), e );
dbgmsg( "Error: select (%d) %s", e, errstr );
dbgmsg( "Error: select (%d) %s", e, errstr );
}
#else
select( nfds, r_fd_set, w_fd_set, c_fd_set, t );