|
|
@ -1086,14 +1086,39 @@ namespace libtorrent |
|
|
|
+ piece_size, v, ec, &pos) == 0) { |
|
|
|
+ piece_size, v, ec, &pos) == 0) { |
|
|
|
|
|
|
|
|
|
|
|
if( v.type() == lazy_entry::dict_t ) { |
|
|
|
if( v.type() == lazy_entry::dict_t ) { |
|
|
|
lazy_entry const* post = v.dict_find("userpost"); |
|
|
|
lazy_entry const* post = v.dict_find_dict("userpost"); |
|
|
|
std::string sig = v.dict_find_string_value("sig_userpost"); |
|
|
|
std::string sig = v.dict_find_string_value("sig_userpost"); |
|
|
|
std::string username = j.storage->info()->name(); |
|
|
|
std::string username = j.storage->info()->name(); |
|
|
|
if( post && sig.size() ) { |
|
|
|
|
|
|
|
|
|
|
|
if( !post || !sig.size() ) { |
|
|
|
|
|
|
|
#ifdef TORRENT_DEBUG |
|
|
|
|
|
|
|
printf("r_p_f_c_a_h: missing post or signature\n"); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
std::string n = post->dict_find_string_value("n"); |
|
|
|
|
|
|
|
int k = post->dict_find_int_value("k",-1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( n != username ) { |
|
|
|
|
|
|
|
#ifdef TORRENT_DEBUG |
|
|
|
|
|
|
|
printf("r_p_f_c_a_h: expected username '%s' got '%s'\n", |
|
|
|
|
|
|
|
username.c_str(), n.c_str()); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} else if( k != j.piece ) { |
|
|
|
|
|
|
|
#ifdef TORRENT_DEBUG |
|
|
|
|
|
|
|
printf("r_p_f_c_a_h: expected piece '%d' got '%d'\n", |
|
|
|
|
|
|
|
j.piece, k); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} else { |
|
|
|
std::pair<char const*, int> postbuf = post->data_section(); |
|
|
|
std::pair<char const*, int> postbuf = post->data_section(); |
|
|
|
*hash_ok = verifySignature( |
|
|
|
*hash_ok = verifySignature( |
|
|
|
std::string(postbuf.first,postbuf.second), |
|
|
|
std::string(postbuf.first,postbuf.second), |
|
|
|
username, sig); |
|
|
|
username, sig); |
|
|
|
|
|
|
|
#ifdef TORRENT_DEBUG |
|
|
|
|
|
|
|
if( !(*hash_ok) ) { |
|
|
|
|
|
|
|
printf("r_p_f_c_a_h: bad signature\n"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|