mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -05:00
fixed free/delete mess in GRouter
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-NewGRouterModel@7863 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e0308eacd2
commit
5967ee535f
@ -1235,7 +1235,7 @@ bool p3GRouter::encryptDataItem(RsGRouterGenericDataItem *item,const RsGxsId& de
|
|||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] item->data_bytes ;
|
free(item->data_bytes) ;
|
||||||
item->data_bytes = encrypted_data ;
|
item->data_bytes = encrypted_data ;
|
||||||
item->data_size = encrypted_size ;
|
item->data_size = encrypted_size ;
|
||||||
item->flags |= RS_GROUTER_DATA_FLAGS_ENCRYPTED ;
|
item->flags |= RS_GROUTER_DATA_FLAGS_ENCRYPTED ;
|
||||||
@ -1279,7 +1279,7 @@ bool p3GRouter::decryptDataItem(RsGRouterGenericDataItem *item)
|
|||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] item->data_bytes ;
|
free(item->data_bytes) ;
|
||||||
item->data_bytes = decrypted_data ;
|
item->data_bytes = decrypted_data ;
|
||||||
item->data_size = decrypted_size ;
|
item->data_size = decrypted_size ;
|
||||||
item->flags &= ~RS_GROUTER_DATA_FLAGS_ENCRYPTED ;
|
item->flags &= ~RS_GROUTER_DATA_FLAGS_ENCRYPTED ;
|
||||||
@ -1410,7 +1410,7 @@ bool p3GRouter::cancel(GRouterMsgPropagationId mid)
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GRouter::sendData(const RsGxsId& destination,const GRouterServiceId& client_id,uint8_t *data, uint32_t data_size,const RsGxsId& signing_id, GRouterMsgPropagationId &propagation_id)
|
bool p3GRouter::sendData(const RsGxsId& destination,const GRouterServiceId& client_id,const uint8_t *data, uint32_t data_size,const RsGxsId& signing_id, GRouterMsgPropagationId &propagation_id)
|
||||||
{
|
{
|
||||||
if(data_size > MAX_GROUTER_DATA_SIZE)
|
if(data_size > MAX_GROUTER_DATA_SIZE)
|
||||||
{
|
{
|
||||||
@ -1428,7 +1428,9 @@ bool p3GRouter::sendData(const RsGxsId& destination,const GRouterServiceId& clie
|
|||||||
|
|
||||||
RsGRouterGenericDataItem *data_item = new RsGRouterGenericDataItem ;
|
RsGRouterGenericDataItem *data_item = new RsGRouterGenericDataItem ;
|
||||||
|
|
||||||
data_item->data_bytes = data ;
|
data_item->data_bytes = (uint8_t*)malloc(data_size) ;
|
||||||
|
memcpy(data_item->data_bytes,data,data_size) ;
|
||||||
|
|
||||||
data_item->data_size = data_size ;
|
data_item->data_size = data_size ;
|
||||||
data_item->routing_id = propagation_id ;
|
data_item->routing_id = propagation_id ;
|
||||||
data_item->randomized_distance = 0 ;
|
data_item->randomized_distance = 0 ;
|
||||||
|
@ -122,8 +122,9 @@ public:
|
|||||||
// the memory. That means item_data will be erase on return. The returned id should be
|
// the memory. That means item_data will be erase on return. The returned id should be
|
||||||
// remembered by the client, so that he knows when the data has been received.
|
// remembered by the client, so that he knows when the data has been received.
|
||||||
// The client id is supplied so that the client can be notified when the data has been received.
|
// The client id is supplied so that the client can be notified when the data has been received.
|
||||||
|
// Data is not modified by the global router.
|
||||||
//
|
//
|
||||||
virtual bool sendData(const RsGxsId& destination, const GRouterServiceId& client_id, uint8_t *data, uint32_t data_size, const RsGxsId& signing_id, GRouterMsgPropagationId& id) ;
|
virtual bool sendData(const RsGxsId& destination, const GRouterServiceId& client_id, const uint8_t *data, uint32_t data_size, const RsGxsId& signing_id, GRouterMsgPropagationId& id) ;
|
||||||
|
|
||||||
// Cancels a given sending order. If called too late, the message might already have left. But this will remove the item from the
|
// Cancels a given sending order. If called too late, the message might already have left. But this will remove the item from the
|
||||||
// re-try list.
|
// re-try list.
|
||||||
|
@ -385,7 +385,13 @@ bool GxsSecurity::encrypt(uint8_t *& out, int & outlen, const uint8_t *in, int i
|
|||||||
if(!EVP_SealInit(&ctx, EVP_aes_128_cbc(), &ek, &eklen, iv, &public_key, 1)) return false;
|
if(!EVP_SealInit(&ctx, EVP_aes_128_cbc(), &ek, &eklen, iv, &public_key, 1)) return false;
|
||||||
|
|
||||||
// now assign memory to out accounting for data, and cipher block size, key length, and key length val
|
// now assign memory to out accounting for data, and cipher block size, key length, and key length val
|
||||||
out = new uint8_t[inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH];
|
out = (uint8_t*)malloc(inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH);
|
||||||
|
|
||||||
|
if(out == NULL)
|
||||||
|
{
|
||||||
|
std::cerr << "gxssecurity::encrypt(): cnnot allocate memory of size " << inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH << " to encrypt data." << std::endl;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
net_ekl = htonl(eklen);
|
net_ekl = htonl(eklen);
|
||||||
memcpy((unsigned char*)out + out_offset, &net_ekl, size_net_ekl);
|
memcpy((unsigned char*)out + out_offset, &net_ekl, size_net_ekl);
|
||||||
@ -400,7 +406,7 @@ bool GxsSecurity::encrypt(uint8_t *& out, int & outlen, const uint8_t *in, int i
|
|||||||
// now encrypt actual data
|
// now encrypt actual data
|
||||||
if(!EVP_SealUpdate(&ctx, (unsigned char*) out + out_offset, &out_currOffset, (unsigned char*) in, inlen))
|
if(!EVP_SealUpdate(&ctx, (unsigned char*) out + out_offset, &out_currOffset, (unsigned char*) in, inlen))
|
||||||
{
|
{
|
||||||
delete[] out ;
|
free(out) ;
|
||||||
out = NULL ;
|
out = NULL ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -411,7 +417,7 @@ bool GxsSecurity::encrypt(uint8_t *& out, int & outlen, const uint8_t *in, int i
|
|||||||
// add padding
|
// add padding
|
||||||
if(!EVP_SealFinal(&ctx, (unsigned char*) out + out_offset, &out_currOffset))
|
if(!EVP_SealFinal(&ctx, (unsigned char*) out + out_offset, &out_currOffset))
|
||||||
{
|
{
|
||||||
delete[] out ;
|
free(out) ;
|
||||||
out = NULL ;
|
out = NULL ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -422,7 +428,7 @@ bool GxsSecurity::encrypt(uint8_t *& out, int & outlen, const uint8_t *in, int i
|
|||||||
// make sure offset has not gone passed valid memory bounds
|
// make sure offset has not gone passed valid memory bounds
|
||||||
if(out_offset > max_outlen)
|
if(out_offset > max_outlen)
|
||||||
{
|
{
|
||||||
delete[] out ;
|
free(out) ;
|
||||||
out = NULL ;
|
out = NULL ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -498,11 +504,17 @@ bool GxsSecurity::decrypt(uint8_t *& out, int & outlen, const uint8_t *in, int i
|
|||||||
std::cerr << "Severe error in " << __PRETTY_FUNCTION__ << ": cannot encrypt. " << std::endl;
|
std::cerr << "Severe error in " << __PRETTY_FUNCTION__ << ": cannot encrypt. " << std::endl;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
out = new uint8_t[inlen - in_offset];
|
out = (uint8_t*)malloc(inlen - in_offset);
|
||||||
|
|
||||||
|
if(out == NULL)
|
||||||
|
{
|
||||||
|
std::cerr << "gxssecurity::decrypt(): cannot allocate memory of size " << inlen - in_offset << " to decrypt data." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!EVP_OpenUpdate(&ctx, (unsigned char*) out, &out_currOffset, (unsigned char*)in + in_offset, inlen - in_offset))
|
if(!EVP_OpenUpdate(&ctx, (unsigned char*) out, &out_currOffset, (unsigned char*)in + in_offset, inlen - in_offset))
|
||||||
{
|
{
|
||||||
delete[] out ;
|
free(out) ;
|
||||||
out = NULL ;
|
out = NULL ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -511,7 +523,7 @@ bool GxsSecurity::decrypt(uint8_t *& out, int & outlen, const uint8_t *in, int i
|
|||||||
|
|
||||||
if(!EVP_OpenFinal(&ctx, (unsigned char*)out + out_currOffset, &out_currOffset))
|
if(!EVP_OpenFinal(&ctx, (unsigned char*)out + out_currOffset, &out_currOffset))
|
||||||
{
|
{
|
||||||
delete[] out ;
|
free(out) ;
|
||||||
out = NULL ;
|
out = NULL ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public:
|
|||||||
// Communication to other services. //
|
// Communication to other services. //
|
||||||
//===================================================//
|
//===================================================//
|
||||||
|
|
||||||
virtual bool sendData(const RsGxsId& destination, const GRouterServiceId& client_id, uint8_t *data, uint32_t data_size, const RsGxsId& signing_id, GRouterMsgPropagationId& id) =0;
|
virtual bool sendData(const RsGxsId& destination, const GRouterServiceId& client_id, const uint8_t *data, uint32_t data_size, const RsGxsId& signing_id, GRouterMsgPropagationId& id) =0;
|
||||||
virtual bool cancel(GRouterMsgPropagationId mid) =0;
|
virtual bool cancel(GRouterMsgPropagationId mid) =0;
|
||||||
|
|
||||||
virtual bool registerKey(const RsGxsId& authentication_id, const GRouterServiceId& client_id,const std::string& description_string)=0 ;
|
virtual bool registerKey(const RsGxsId& authentication_id, const GRouterServiceId& client_id,const std::string& description_string)=0 ;
|
||||||
|
@ -2263,6 +2263,8 @@ void p3MsgService::sendDistantMsgItem(RsMsgItem *msgitem)
|
|||||||
GRouterMsgPropagationId grouter_message_id ;
|
GRouterMsgPropagationId grouter_message_id ;
|
||||||
mGRouter->sendData(destination_key_id,GROUTER_CLIENT_ID_MESSAGES,msg_serialized_data,msg_serialized_rssize,signing_key_id,grouter_message_id) ;
|
mGRouter->sendData(destination_key_id,GROUTER_CLIENT_ID_MESSAGES,msg_serialized_data,msg_serialized_rssize,signing_key_id,grouter_message_id) ;
|
||||||
|
|
||||||
|
delete[] msg_serialized_data ;
|
||||||
|
|
||||||
// now store the grouter id along with the message id, so that we can keep track of received messages
|
// now store the grouter id along with the message id, so that we can keep track of received messages
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -218,6 +218,8 @@ void GlobalRouterStatisticsWidget::updateContent()
|
|||||||
oy += celly ;
|
oy += celly ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
oy += celly ;
|
||||||
|
|
||||||
QString prob_string ;
|
QString prob_string ;
|
||||||
painter.setFont(times_f) ;
|
painter.setFont(times_f) ;
|
||||||
QString Q = tr("Routing matrix (") ;
|
QString Q = tr("Routing matrix (") ;
|
||||||
@ -252,8 +254,6 @@ void GlobalRouterStatisticsWidget::updateContent()
|
|||||||
oy += celly ;
|
oy += celly ;
|
||||||
}
|
}
|
||||||
|
|
||||||
oy += celly ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
oy += celly ;
|
oy += celly ;
|
||||||
|
Loading…
Reference in New Issue
Block a user