Browse Source

make sure strSpamUser is valid before using it to sign message

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
d2d64bfed2
  1. 13
      src/main.cpp

13
src/main.cpp

@ -70,7 +70,7 @@ int64 nHPSTimerStart = 0;
int64 nTransactionFee = 0; int64 nTransactionFee = 0;
string strSpamMessage = "Promoted posts are needed to run the network infrastructure. If you want to help, start generating blocks and advertise. [en]"; string strSpamMessage = "Promoted posts are needed to run the network infrastructure. If you want to help, start generating blocks and advertise. [en]";
string strSpamUser = "nobody"; // [MF] FIXME: authenticy check needed string strSpamUser = "nobody";
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -3581,14 +3581,15 @@ static bool CreateSpamMsgTx(CTransaction &txNew, std::vector<unsigned char> &sal
std::string strUsername = strSpamUser; std::string strUsername = strSpamUser;
CKeyID keyID; CKeyID keyID;
if( strSpamUser != "nobody" && !pwalletMain->GetKeyIdFromUsername(strSpamUser, keyID) ) { if( strSpamUser != "nobody" ) {
if( pwalletMain->vchDefaultKey.IsValid() ) { // check both wallet and block chain if they know about this user
keyID = pwalletMain->vchDefaultKey.GetID(); uint256 txid = SerializeHash(make_pair(strSpamUser,-1));
strUsername = pwalletMain->mapKeyMetadata[keyID].username; if( !pblocktree->HaveTxIndex(txid) ||
} else { !pwalletMain->GetKeyIdFromUsername(strSpamUser, keyID) ) {
strUsername = "nobody"; strUsername = "nobody";
} }
} }
printf("CreateSpamMsgTx: keyId = %s\n", keyID.ToString().c_str() ); printf("CreateSpamMsgTx: keyId = %s\n", keyID.ToString().c_str() );
// compute message hash and sign it // compute message hash and sign it

Loading…
Cancel
Save