Skip to content

Commit

Permalink
fix: add missing null-checks in s2n_connection.c (#4754)
Browse files Browse the repository at this point in the history
  • Loading branch information
jouho authored Sep 5, 2024
1 parent 08d413a commit 7ba4a2f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tls/s2n_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ struct s2n_connection *s2n_connection_new(s2n_mode mode)

static int s2n_connection_zero(struct s2n_connection *conn, int mode, struct s2n_config *config)
{
POSIX_ENSURE_REF(conn);
POSIX_ENSURE_REF(config);

/* Zero the whole connection structure */
POSIX_CHECKED_MEMSET(conn, 0, sizeof(struct s2n_connection));

Expand All @@ -144,6 +147,8 @@ S2N_RESULT s2n_connection_wipe_all_keyshares(struct s2n_connection *conn)

static int s2n_connection_wipe_keys(struct s2n_connection *conn)
{
POSIX_ENSURE_REF(conn);

/* Free any server key received (we may not have completed a
* handshake, so this may not have been free'd yet) */
POSIX_GUARD(s2n_pkey_free(&conn->handshake_params.server_public_key));
Expand Down Expand Up @@ -420,6 +425,8 @@ int s2n_connection_release_buffers(struct s2n_connection *conn)

int s2n_connection_free_handshake(struct s2n_connection *conn)
{
POSIX_ENSURE_REF(conn);

/* We are done with the handshake */
POSIX_GUARD_RESULT(s2n_handshake_hashes_free(&conn->handshake.hashes));
POSIX_GUARD_RESULT(s2n_prf_free(conn));
Expand Down Expand Up @@ -458,6 +465,8 @@ int s2n_connection_free_handshake(struct s2n_connection *conn)
*/
int s2n_connection_wipe(struct s2n_connection *conn)
{
POSIX_ENSURE_REF(conn);

/* First make a copy of everything we'd like to save, which isn't very much. */
int mode = conn->mode;
struct s2n_config *config = conn->config;
Expand Down Expand Up @@ -790,6 +799,8 @@ int s2n_connection_get_client_auth_type(struct s2n_connection *conn,

int s2n_connection_set_client_auth_type(struct s2n_connection *conn, s2n_cert_auth_type client_cert_auth_type)
{
POSIX_ENSURE_REF(conn);

conn->client_cert_auth_type_overridden = 1;
conn->client_cert_auth_type = client_cert_auth_type;
return 0;
Expand Down

0 comments on commit 7ba4a2f

Please sign in to comment.