解密失败时申请的内存未释放导致内存泄漏
This commit is contained in:
@@ -172,6 +172,8 @@ static void quic_decrypt_message(quic_pp_cipher *pp_cipher, const char *payload,
|
|||||||
buffer_length = length - (pkn_len + 16);
|
buffer_length = length - (pkn_len + 16);
|
||||||
if (buffer_length == 0 || buffer_length >1500)
|
if (buffer_length == 0 || buffer_length >1500)
|
||||||
{
|
{
|
||||||
|
g_free(header);
|
||||||
|
header=NULL;
|
||||||
*error = (const guchar *)"Decryption not possible, ciphertext is too short or too long";
|
*error = (const guchar *)"Decryption not possible, ciphertext is too short or too long";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -185,30 +187,48 @@ static void quic_decrypt_message(quic_pp_cipher *pp_cipher, const char *payload,
|
|||||||
|
|
||||||
gcry_cipher_reset(pp_cipher->pp_cipher);
|
gcry_cipher_reset(pp_cipher->pp_cipher);
|
||||||
err = gcry_cipher_setiv(pp_cipher->pp_cipher, nonce, TLS13_AEAD_NONCE_LENGTH);
|
err = gcry_cipher_setiv(pp_cipher->pp_cipher, nonce, TLS13_AEAD_NONCE_LENGTH);
|
||||||
if (err) {
|
if (err)
|
||||||
//printf("Decryption (setiv) failed: %s\n", gcry_strerror(err));
|
{
|
||||||
|
g_free(header);
|
||||||
|
header=NULL;
|
||||||
|
g_free(buffer);
|
||||||
|
buffer=NULL;
|
||||||
*error = (const guchar *)"Decryption (setiv) failed";
|
*error = (const guchar *)"Decryption (setiv) failed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// associated data (A) is the contents of QUIC header
|
// associated data (A) is the contents of QUIC header
|
||||||
err = gcry_cipher_authenticate(pp_cipher->pp_cipher, header, header_length);
|
err = gcry_cipher_authenticate(pp_cipher->pp_cipher, header, header_length);
|
||||||
if (err) {
|
if (err)
|
||||||
//printf("Decryption (authenticate) failed: %s\n", gcry_strerror(err));
|
{
|
||||||
|
g_free(header);
|
||||||
|
header=NULL;
|
||||||
|
g_free(buffer);
|
||||||
|
buffer=NULL;
|
||||||
*error = (const guchar *)"Decryption (authenticate) failed";
|
*error = (const guchar *)"Decryption (authenticate) failed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output ciphertext (C)
|
// Output ciphertext (C)
|
||||||
err = gcry_cipher_decrypt(pp_cipher->pp_cipher, buffer, buffer_length, NULL, 0);
|
err = gcry_cipher_decrypt(pp_cipher->pp_cipher, buffer, buffer_length, NULL, 0);
|
||||||
if (err) {
|
if (err)
|
||||||
|
{
|
||||||
|
g_free(header);
|
||||||
|
header=NULL;
|
||||||
|
g_free(buffer);
|
||||||
|
buffer=NULL;
|
||||||
//printf("Decryption (decrypt) failed: %s\n", gcry_strerror(err));
|
//printf("Decryption (decrypt) failed: %s\n", gcry_strerror(err));
|
||||||
*error = (const guchar *)"Decryption (decrypt) failed";
|
*error = (const guchar *)"Decryption (decrypt) failed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = gcry_cipher_checktag(pp_cipher->pp_cipher, atag, 16);
|
err = gcry_cipher_checktag(pp_cipher->pp_cipher, atag, 16);
|
||||||
if (err) {
|
if (err)
|
||||||
|
{
|
||||||
|
g_free(header);
|
||||||
|
header=NULL;
|
||||||
|
g_free(buffer);
|
||||||
|
buffer=NULL;
|
||||||
//printf("Decryption (checktag) failed: %s\n", gcry_strerror(err));
|
//printf("Decryption (checktag) failed: %s\n", gcry_strerror(err));
|
||||||
*error = (const guchar *)"Decryption (checktag) failed";
|
*error = (const guchar *)"Decryption (checktag) failed";
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user