mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
fixed memory leaks
This commit is contained in:
@@ -74,6 +74,7 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i
|
||||
}
|
||||
|
||||
symkey = pcp_scrypt(ptx, passphrase, strlen(passphrase), salt, 90);
|
||||
ucfree(passphrase, strlen(passwd)+1);
|
||||
free(salt);
|
||||
}
|
||||
else if(head == PCP_ASYM_CIPHER || head == PCP_ASYM_CIPHER_SIG) {
|
||||
@@ -124,10 +125,13 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i
|
||||
goto errde3;
|
||||
}
|
||||
|
||||
if(symkey == NULL)
|
||||
if(symkey == NULL) {
|
||||
dlen = pcp_decrypt_stream(ptx, pin, pout, secret, NULL, verify);
|
||||
else
|
||||
}
|
||||
else {
|
||||
dlen = pcp_decrypt_stream(ptx, pin, pout, NULL, symkey, verify);
|
||||
ucfree(symkey, 64);
|
||||
}
|
||||
|
||||
ps_close(pin);
|
||||
ps_close(pout);
|
||||
@@ -142,6 +146,9 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i
|
||||
|
||||
|
||||
errde3:
|
||||
if(symkey != NULL)
|
||||
ucfree(symkey, 64);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -174,6 +181,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
|
||||
memcpy(salt, stsalt, 90);
|
||||
symkey = pcp_scrypt(ptx, passphrase, strlen(passphrase), salt, 90);
|
||||
free(salt);
|
||||
ucfree(passphrase, strlen(passwd)+1);
|
||||
}
|
||||
else if(id != NULL && recipient == NULL) {
|
||||
/* lookup by id */
|
||||
@@ -282,10 +290,13 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
|
||||
ps_armor(pout, PCP_BLOCK_SIZE/2);
|
||||
}
|
||||
|
||||
if(self == 1)
|
||||
if(self == 1) {
|
||||
clen = pcp_encrypt_stream_sym(ptx, pin, pout, symkey, 0, NULL);
|
||||
else
|
||||
ucfree(symkey, 64);
|
||||
}
|
||||
else {
|
||||
clen = pcp_encrypt_stream(ptx, pin, pout, secret, pubhash, signcrypt);
|
||||
}
|
||||
|
||||
if(armor == 1) {
|
||||
ps_finish(pout);
|
||||
@@ -318,6 +329,9 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
|
||||
erren2:
|
||||
pcphash_cleanpub(pubhash);
|
||||
|
||||
if(symkey != NULL)
|
||||
ucfree(symkey, 64);
|
||||
|
||||
erren3:
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -64,8 +64,9 @@ int pcptext_infile(char *infile) {
|
||||
fprintf(stdout, "%s isn't properly Z85 encoded - unknown file type.\n", infile);
|
||||
goto errtinf1;
|
||||
}
|
||||
|
||||
/* FIXME: try to import pk or sk */
|
||||
else
|
||||
/* FIXME: try to import pk or sk */
|
||||
free(bin);
|
||||
|
||||
/* still there? */
|
||||
fprintf(stdout, "%s looks Z85 encoded but otherwise unknown and is possibly encrypted.\n", infile);
|
||||
|
||||
@@ -67,6 +67,7 @@ int pcpsign(char *infile, char *outfile, char *passwd, int z85, int detach) {
|
||||
}
|
||||
|
||||
secret = pcpkey_decrypt(ptx, secret, passphrase);
|
||||
ucfree(passphrase, strlen(passwd)+1);
|
||||
if(secret == NULL)
|
||||
goto errs1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user