mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed memory leaks
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5167 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
ad5ca59a7a
commit
ba56f5f611
@ -23,12 +23,12 @@ std::string PGPIdType::toStdString() const
|
||||
{
|
||||
static const char out[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } ;
|
||||
|
||||
std::string res ;
|
||||
std::string res(KEY_ID_SIZE*2,' ') ;
|
||||
|
||||
for(int j = 0; j < KEY_ID_SIZE; j++)
|
||||
{
|
||||
res += out[ (bytes[j]>>4) ] ;
|
||||
res += out[ bytes[j] & 0xf ] ;
|
||||
res[2*j ] = out[ (bytes[j]>>4) ] ;
|
||||
res[2*j+1] = out[ bytes[j] & 0xf ] ;
|
||||
}
|
||||
|
||||
return res ;
|
||||
@ -37,12 +37,12 @@ std::string PGPFingerprintType::toStdString() const
|
||||
{
|
||||
static const char out[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } ;
|
||||
|
||||
std::string res ;
|
||||
std::string res(KEY_FINGERPRINT_SIZE*2,' ') ;
|
||||
|
||||
for(int j = 0; j < KEY_FINGERPRINT_SIZE; j++)
|
||||
{
|
||||
res += out[ (bytes[j]>>4) ] ;
|
||||
res += out[ bytes[j] & 0xf ] ;
|
||||
res[2*j ] = out[ (bytes[j]>>4) ] ;
|
||||
res[2*j+1] = out[ bytes[j] & 0xf ] ;
|
||||
}
|
||||
|
||||
return res ;
|
||||
@ -449,7 +449,7 @@ bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::stri
|
||||
|
||||
// 7 - validate own signature and update certificate.
|
||||
|
||||
validateAndUpdateSignatures(_public_keyring_map[ pgpId.toStdString() ],getPublicKey(pgpId)) ;
|
||||
// validateAndUpdateSignatures(_public_keyring_map[ pgpId.toStdString() ],getPublicKey(pgpId)) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
@ -5,3 +5,11 @@
|
||||
|
||||
/* for silencing unused parameter warnings */
|
||||
#define OPS_USED(x) (x)=(x)
|
||||
|
||||
/* for tests, flag to tell gpg not to use blocking randomness */
|
||||
#define GNUPG_QUICK_RANDOM "--quick-random"
|
||||
|
||||
/* Avoid a bunch of #ifs */
|
||||
#ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
#endif
|
||||
|
@ -1124,11 +1124,9 @@ ops_write_literal_data_from_file(const char *filename,
|
||||
unsigned char buf[1024];
|
||||
ops_memory_t* mem=NULL;
|
||||
size_t len=0;
|
||||
#ifdef WINDOWS_SYS
|
||||
|
||||
fd=open(filename,O_RDONLY | O_BINARY);
|
||||
#else
|
||||
fd=open(filename,O_RDONLY);
|
||||
#endif
|
||||
|
||||
if (fd < 0)
|
||||
return ops_false;
|
||||
|
||||
@ -1180,11 +1178,9 @@ ops_memory_t* ops_write_mem_from_file(const char *filename, int* errnum)
|
||||
ops_memory_t* mem=NULL;
|
||||
|
||||
*errnum=0;
|
||||
#ifdef WINDOWS_SYS
|
||||
|
||||
fd=open(filename,O_RDONLY | O_BINARY);
|
||||
#else
|
||||
fd=open(filename,O_RDONLY);
|
||||
#endif
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
*errnum=errno;
|
||||
@ -1234,9 +1230,8 @@ int ops_write_file_from_buf(const char *filename, const char* buf,
|
||||
flags |= O_TRUNC;
|
||||
else
|
||||
flags |= O_EXCL;
|
||||
#ifdef WINDOWS_SYS
|
||||
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
|
||||
fd=open(filename,flags, 0600);
|
||||
if (fd < 0)
|
||||
|
@ -691,11 +691,9 @@ ops_boolean_t ops_keyring_read_from_file(ops_keyring_t *keyring, const ops_boole
|
||||
|
||||
// ops_parse_options(pinfo,OPS_PTAG_SS_ALL,OPS_PARSE_RAW);
|
||||
ops_parse_options(pinfo,OPS_PTAG_SS_ALL,OPS_PARSE_PARSED);
|
||||
#ifdef WINDOWS_SYS
|
||||
|
||||
fd=open(filename,O_RDONLY | O_BINARY);
|
||||
#else
|
||||
fd=open(filename,O_RDONLY);
|
||||
#endif
|
||||
|
||||
if(fd < 0)
|
||||
{
|
||||
ops_parse_info_delete(pinfo);
|
||||
|
@ -139,9 +139,7 @@ int ops_setup_file_write(ops_create_info_t **cinfo, const char* filename, ops_bo
|
||||
flags |= O_TRUNC;
|
||||
else
|
||||
flags |= O_EXCL;
|
||||
#ifdef WINDOWS_SYS
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
|
||||
fd=open(filename, flags, 0600);
|
||||
if(fd < 0)
|
||||
@ -181,11 +179,8 @@ int ops_setup_file_append(ops_create_info_t **cinfo, const char* filename)
|
||||
* initialise needed structures for writing to file
|
||||
*/
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
fd=open(filename,O_WRONLY | O_APPEND | O_BINARY, 0600);
|
||||
#else
|
||||
fd=open(filename,O_WRONLY | O_APPEND , 0600);
|
||||
#endif
|
||||
|
||||
if(fd < 0)
|
||||
{
|
||||
perror(filename);
|
||||
@ -230,11 +225,8 @@ int ops_setup_file_read(ops_parse_info_t **pinfo, const char *filename,
|
||||
* initialise needed structures for reading
|
||||
*/
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
fd=open(filename,O_RDONLY | O_BINARY);
|
||||
#else
|
||||
fd=open(filename,O_RDONLY );
|
||||
#endif
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
perror(filename);
|
||||
|
@ -958,11 +958,9 @@ ops_boolean_t ops_sign_file_as_cleartext(const char* input_filename,
|
||||
ops_boolean_t use_armour=ops_true;
|
||||
|
||||
// open file to sign
|
||||
#ifdef WINDOWS_SYS
|
||||
|
||||
fd_in=open(input_filename, O_RDONLY | O_BINARY);
|
||||
#else
|
||||
fd_in=open(input_filename, O_RDONLY );
|
||||
#endif
|
||||
|
||||
if(fd_in < 0)
|
||||
{
|
||||
return ops_false;
|
||||
|
@ -116,9 +116,11 @@ static int keydata_reader(void *dest,size_t length,ops_error_t **errors,
|
||||
return length;
|
||||
}
|
||||
|
||||
static void free_signature_info(ops_signature_info_t *sig)
|
||||
static void free_signature_info(ops_signature_info_t *sig,int n)
|
||||
{
|
||||
free (sig->v4_hashed_data);
|
||||
int i ;
|
||||
for(i=0;i<n;++i)
|
||||
free (sig[i].v4_hashed_data);
|
||||
free (sig);
|
||||
}
|
||||
|
||||
@ -145,7 +147,6 @@ static void add_sig_to_valid_list(ops_validate_result_t * result, const ops_sign
|
||||
result->valid_sigs=realloc(result->valid_sigs, newsize);
|
||||
|
||||
// copy key ptr to array
|
||||
start=(sizeof *sig) * (result->valid_count-1);
|
||||
copy_signature_info(&result->valid_sigs[result->valid_count-1],sig);
|
||||
}
|
||||
|
||||
@ -165,7 +166,6 @@ static void add_sig_to_invalid_list(ops_validate_result_t * result, const ops_si
|
||||
result->invalid_sigs=realloc(result->invalid_sigs, newsize);
|
||||
|
||||
// copy key ptr to array
|
||||
start=(sizeof *sig) * (result->invalid_count-1);
|
||||
copy_signature_info(&result->invalid_sigs[result->invalid_count-1],sig);
|
||||
}
|
||||
|
||||
@ -185,7 +185,6 @@ static void add_sig_to_unknown_list(ops_validate_result_t * result, const ops_si
|
||||
result->unknown_sigs=realloc(result->unknown_sigs, newsize);
|
||||
|
||||
// copy key id to array
|
||||
start=OPS_KEY_ID_SIZE * (result->unknown_signer_count-1);
|
||||
copy_signature_info(&result->unknown_sigs[result->unknown_signer_count-1],sig);
|
||||
}
|
||||
|
||||
@ -607,11 +606,11 @@ void ops_validate_result_free(ops_validate_result_t *result)
|
||||
return;
|
||||
|
||||
if (result->valid_sigs)
|
||||
free_signature_info(result->valid_sigs);
|
||||
free_signature_info(result->valid_sigs,result->valid_count);
|
||||
if (result->invalid_sigs)
|
||||
free_signature_info(result->invalid_sigs);
|
||||
free_signature_info(result->invalid_sigs,result->invalid_count);
|
||||
if (result->unknown_sigs)
|
||||
free_signature_info(result->unknown_sigs);
|
||||
free_signature_info(result->unknown_sigs,result->unknown_signer_count);
|
||||
|
||||
free(result);
|
||||
result=NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user