mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
fixed bug in pcp_encrypt_stream_sym(), freed buffer before using it in update_hash()
This commit is contained in:
@@ -411,8 +411,8 @@ size_t pcp_encrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream *out, byte *
|
||||
havehead = 1: no header, being called from asym...
|
||||
*/
|
||||
|
||||
byte *buf_nonce;
|
||||
byte *buf_cipher;
|
||||
byte *buf_nonce = NULL;
|
||||
byte *buf_cipher = NULL;
|
||||
byte *in_buf = NULL;
|
||||
size_t cur_bufsize = 0;
|
||||
size_t out_size = 0;
|
||||
@@ -461,16 +461,15 @@ size_t pcp_encrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream *out, byte *
|
||||
ps_write(out, buf_nonce, crypto_secretbox_NONCEBYTES);
|
||||
ps_write(out, buf_cipher, es);
|
||||
|
||||
free(buf_nonce);
|
||||
free(buf_cipher);
|
||||
out_size += crypto_secretbox_NONCEBYTES + es;
|
||||
|
||||
if(recsign != NULL)
|
||||
crypto_generichash_update(st, buf_cipher, es);
|
||||
//crypto_generichash_update(st, in_buf, cur_bufsize);
|
||||
|
||||
}
|
||||
|
||||
free(buf_nonce);
|
||||
free(buf_cipher);
|
||||
|
||||
if(ps_err(out) != 0) {
|
||||
fatal(ptx, "Failed to write encrypted output!\n");
|
||||
goto errsym1;
|
||||
@@ -578,7 +577,6 @@ size_t pcp_decrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte *
|
||||
|
||||
if(recverify != NULL)
|
||||
crypto_generichash_update(st, buf_cipher, ciphersize);
|
||||
//crypto_generichash_update(st, buf_clear, ciphersize - PCP_CRYPTO_ADD);
|
||||
|
||||
free(buf_clear);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user