mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-02-08 21:04:14 +00:00
more consistency checks of userpost
This commit is contained in:
parent
6fb557e33c
commit
15d8e3397c
@ -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() ) {
|
|
||||||
std::pair<char const*, int> postbuf = post->data_section();
|
if( !post || !sig.size() ) {
|
||||||
*hash_ok = verifySignature(
|
#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();
|
||||||
|
*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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user