mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 16:09:37 -05:00
error handling in pgphandler.cc
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6938 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3e88b54ae3
commit
5800069acf
@ -1182,21 +1182,28 @@ bool PGPHandler::encryptDataBin(const PGPIdType& key_id,const void *data, const
|
||||
ops_create_info_t *info;
|
||||
ops_memory_t *buf = NULL ;
|
||||
ops_setup_memory_write(&info, &buf, 0);
|
||||
bool res = true;
|
||||
|
||||
ops_encrypt_stream(info, public_key, NULL, ops_false, ops_false);
|
||||
if(!ops_encrypt_stream(info, public_key, NULL, ops_false, ops_false))
|
||||
{
|
||||
std::cerr << "Encryption failed." << std::endl;
|
||||
res = false ;
|
||||
}
|
||||
|
||||
ops_write(data,len,info);
|
||||
ops_writer_close(info);
|
||||
ops_create_info_delete(info);
|
||||
|
||||
int tlen = ops_memory_get_length(buf) ;
|
||||
bool res ;
|
||||
|
||||
if( (int)*encrypted_data_len >= tlen)
|
||||
{
|
||||
memcpy(encrypted_data,ops_memory_get_data(buf),tlen) ;
|
||||
*encrypted_data_len = tlen ;
|
||||
res = true ;
|
||||
if(res)
|
||||
{
|
||||
memcpy(encrypted_data,ops_memory_get_data(buf),tlen) ;
|
||||
*encrypted_data_len = tlen ;
|
||||
res = true ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user