From e77a18c88218171c89935ab124d5ed0d529b1ca5 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 1 Jul 2007 02:54:37 +0000 Subject: [PATCH] make the "Error while parsing bencoded data" more helpful by showing the bad bencoded data. (though the string might be very long...) --- gtk/tr_prefs.c | 2 +- libtransmission/metainfo.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gtk/tr_prefs.c b/gtk/tr_prefs.c index 4034ec60a..2a19e77ae 100644 --- a/gtk/tr_prefs.c +++ b/gtk/tr_prefs.c @@ -183,7 +183,7 @@ defs_bool[] = { FALSE, PREF_ID_DOWNLIMIT, TRUE }, { FALSE, -1, FALSE }, /* PREF_ID_USEUPLIMIT */ - { TRUE, PREF_ID_UPLIMIT, TRUE }, + { FALSE, PREF_ID_UPLIMIT, TRUE }, { FALSE, -1, FALSE }, /* PREF_ID_ASKDIR */ { FALSE, PREF_ID_DIR, FALSE }, diff --git a/libtransmission/metainfo.c b/libtransmission/metainfo.c index 0e513e105..4de84a255 100644 --- a/libtransmission/metainfo.c +++ b/libtransmission/metainfo.c @@ -157,7 +157,7 @@ tr_metainfoParseHash( tr_info_t * inf, const char * tag, const char * hash ) return TR_OK; } -int +static int realparse( tr_info_t * inf, const uint8_t * buf, size_t size ) { benc_val_t meta, * beInfo, * val, * val2; @@ -166,7 +166,7 @@ realparse( tr_info_t * inf, const uint8_t * buf, size_t size ) /* Parse bencoded infos */ if( tr_bencLoad( buf, size, &meta, NULL ) ) { - tr_err( "Error while parsing bencoded data" ); + tr_err( "Error while parsing bencoded data [%*.*s]", (int)size, (int)size, (char*)buf ); return TR_EINVALID; } @@ -523,7 +523,7 @@ static char * announceToScrape( const char * announce ) return scrape; } -void +static void savedname( char * name, size_t len, const char * hash, const char * tag ) { const char * torDir = tr_getTorrentsDirectory (); @@ -548,7 +548,8 @@ void tr_metainfoRemoveSaved( const char * hashString, const char * tag ) unlink( file ); } -uint8_t * readtorrent( const char * path, size_t * size ) +static uint8_t * +readtorrent( const char * path, size_t * size ) { uint8_t * buf; struct stat sb; @@ -603,8 +604,9 @@ uint8_t * readtorrent( const char * path, size_t * size ) } /* Save a copy of the torrent file in the saved torrent directory */ -int savetorrent( const char * hash, const char * tag, - const uint8_t * buf, size_t buflen ) +static int +savetorrent( const char * hash, const char * tag, + const uint8_t * buf, size_t buflen ) { char path[MAX_PATH_LENGTH]; FILE * file; @@ -628,7 +630,7 @@ int savetorrent( const char * hash, const char * tag, return TR_OK; } -int +static int parseFiles( tr_info_t * inf, benc_val_t * name, benc_val_t * files, benc_val_t * length ) {