mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-23 04:54:30 +00:00
dont trust getBestHeight == 0
This commit is contained in:
parent
0df5c54166
commit
d1ec27e01a
@ -1092,8 +1092,8 @@ void node_impl::incoming_request(msg const& m, entry& e)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_keys[mk_height]->int_value() > getBestHeight() ) {
|
if (msg_keys[mk_height]->int_value() > getBestHeight() && getBestHeight()) {
|
||||||
incoming_error(e, "future messages not allowed");
|
incoming_error(e, "height > getBestHeight");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,7 +557,7 @@ bool acceptSignedPost(char const *data, int data_size, std::string username, int
|
|||||||
} else if( !validatePostNumberForUser(username, k) ) {
|
} else if( !validatePostNumberForUser(username, k) ) {
|
||||||
sprintf(errbuf,"too much posts from user '%s' rejecting post",
|
sprintf(errbuf,"too much posts from user '%s' rejecting post",
|
||||||
username.c_str());
|
username.c_str());
|
||||||
} else if( height < 0 || height > getBestHeight() ) {
|
} else if( height < 0 || (height > getBestHeight() && getBestHeight()) ) {
|
||||||
sprintf(errbuf,"post from future not accepted (height: %d > %d)",
|
sprintf(errbuf,"post from future not accepted (height: %d > %d)",
|
||||||
height, getBestHeight());
|
height, getBestHeight());
|
||||||
} else if( msg.size() && msg.size() > 140 ) {
|
} else if( msg.size() && msg.size() > 140 ) {
|
||||||
@ -617,7 +617,9 @@ bool validatePostNumberForUser(std::string const &username, int k)
|
|||||||
|
|
||||||
CBlockIndex* pblockindex = mapBlockIndex[hashBlock];
|
CBlockIndex* pblockindex = mapBlockIndex[hashBlock];
|
||||||
|
|
||||||
if( k < 0 || k > 2*(getBestHeight() - pblockindex->nHeight) + 10)
|
if( k < 0 )
|
||||||
|
return false;
|
||||||
|
if( getBestHeight() && k > 2*(getBestHeight() - pblockindex->nHeight) + 20)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user