77#include <stdlib.h>
88#include <string.h>
99
10+ #include "trilogy/allocator.h"
1011#include "trilogy/client.h"
1112#include "trilogy/error.h"
1213
@@ -566,7 +567,7 @@ static int encrypt_password_with_public_key(const uint8_t *scramble, size_t scra
566567 return TRILOGY_MEM_ERROR ;
567568 }
568569 size_t plaintext_len = password_len + 1 ;
569- uint8_t * plaintext = malloc (plaintext_len );
570+ uint8_t * plaintext = xmalloc (plaintext_len );
570571
571572 if (plaintext == NULL ) {
572573 return TRILOGY_MEM_ERROR ;
@@ -585,7 +586,7 @@ static int encrypt_password_with_public_key(const uint8_t *scramble, size_t scra
585586
586587 BIO * bio = BIO_new_mem_buf ((void * )key_data , (int )key_data_len );
587588 if (bio == NULL ) {
588- free (plaintext );
589+ xfree (plaintext );
589590 return TRILOGY_OPENSSL_ERR ;
590591 }
591592
@@ -600,7 +601,7 @@ static int encrypt_password_with_public_key(const uint8_t *scramble, size_t scra
600601 if (public_key == NULL ) {
601602 ERR_clear_error ();
602603 memset (plaintext , 0 , plaintext_len );
603- free (plaintext );
604+ xfree (plaintext );
604605 return TRILOGY_AUTH_PLUGIN_ERROR ;
605606 }
606607
@@ -609,7 +610,7 @@ static int encrypt_password_with_public_key(const uint8_t *scramble, size_t scra
609610 if (key_size <= 0 ) {
610611 EVP_PKEY_free (public_key );
611612 memset (plaintext , 0 , plaintext_len );
612- free (plaintext );
613+ xfree (plaintext );
613614 return TRILOGY_AUTH_PLUGIN_ERROR ;
614615 }
615616 ciphertext_len = (size_t )key_size ;
@@ -628,11 +629,11 @@ static int encrypt_password_with_public_key(const uint8_t *scramble, size_t scra
628629 RSA_free (public_key );
629630#endif
630631 memset (plaintext , 0 , plaintext_len );
631- free (plaintext );
632+ xfree (plaintext );
632633 return TRILOGY_AUTH_PLUGIN_ERROR ;
633634 }
634635
635- ciphertext = malloc (ciphertext_len );
636+ ciphertext = xmalloc (ciphertext_len );
636637
637638 if (ciphertext == NULL ) {
638639#if OPENSSL_VERSION_NUMBER >= 0x30000000L
@@ -641,7 +642,7 @@ static int encrypt_password_with_public_key(const uint8_t *scramble, size_t scra
641642 RSA_free (public_key );
642643#endif
643644 memset (plaintext , 0 , plaintext_len );
644- free (plaintext );
645+ xfree (plaintext );
645646 return TRILOGY_MEM_ERROR ;
646647 }
647648
@@ -676,13 +677,13 @@ static int encrypt_password_with_public_key(const uint8_t *scramble, size_t scra
676677#endif
677678
678679 memset (plaintext , 0 , plaintext_len );
679- free (plaintext );
680+ xfree (plaintext );
680681
681682 if (rc == TRILOGY_OK ) {
682683 * encrypted_out = ciphertext ;
683684 } else {
684685 memset (ciphertext , 0 , ciphertext_len );
685- free (ciphertext );
686+ xfree (ciphertext );
686687 }
687688
688689 return rc ;
@@ -755,7 +756,7 @@ static int handle_fast_auth_fail(trilogy_conn_t *conn, trilogy_handshake_t *hand
755756
756757 rc = send_auth_buffer (conn , encrypted , encrypted_len );
757758 memset (encrypted , 0 , encrypted_len );
758- free (encrypted );
759+ xfree (encrypted );
759760
760761 if (rc < 0 ) {
761762 return rc ;
0 commit comments