Changeset 9830
- Timestamp:
- Dec 28, 2009, 12:35:29 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/metainfo.c
r9681 r9830 126 126 127 127 static tr_bool 128 getfile( char ** setme, 129 const char * root, 130 tr_benc * path ) 128 path_is_suspicious( const char * path ) 129 { 130 return ( path == NULL ) 131 || ( strstr( path, "../" ) != NULL ); 132 } 133 134 static tr_bool 135 getfile( char ** setme, const char * root, tr_benc * path ) 131 136 { 132 137 tr_bool success = FALSE; … … 134 139 if( tr_bencIsList( path ) ) 135 140 { 141 int i; 142 const int n = tr_bencListSize( path ); 136 143 struct evbuffer * buf = evbuffer_new( ); 137 int n = tr_bencListSize( path );138 int i;139 144 140 145 evbuffer_add( buf, root, strlen( root ) ); … … 142 147 { 143 148 const char * str; 144 if( tr_bencGetStr( tr_bencListChild( path, i ), &str ) 145 && strcmp( str, ".." ) ) 149 if( tr_bencGetStr( tr_bencListChild( path, i ), &str ) ) 146 150 { 147 151 evbuffer_add( buf, TR_PATH_DELIMITER_STR, 1 ); … … 156 160 } 157 161 162 if( ( *setme != NULL ) && path_is_suspicious( *setme ) ) 163 { 164 tr_free( *setme ); 165 *setme = NULL; 166 success = FALSE; 167 } 168 158 169 return success; 159 170 } 160 171 161 172 static const char* 162 parseFiles( tr_info * inf, 163 tr_benc * files, 164 const tr_benc * length ) 173 parseFiles( tr_info * inf, tr_benc * files, const tr_benc * length ) 165 174 { 166 175 int64_t len; … … 201 210 else if( tr_bencGetInt( length, &len ) ) /* single-file mode */ 202 211 { 212 if( path_is_suspicious( inf->name ) ) 213 return "path"; 214 203 215 inf->isMultifile = 0; 204 216 inf->fileCount = 1;
Note: See TracChangeset
for help on using the changeset viewer.