Skip to content

Commit

Permalink
add UBSAN option
Browse files Browse the repository at this point in the history
  • Loading branch information
jmayclin committed Feb 24, 2024
1 parent fcc0d40 commit 65c06aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,13 @@ if(ASAN)
target_link_options(${PROJECT_NAME} PUBLIC -fsanitize=address)
endif()

if(TSAN OR ASAN)
if (UBSAN)
target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=undefined -fno-sanitize-recover=all -DS2N_ADDRESS_SANITIZER=1)
target_link_options(${PROJECT_NAME} PUBLIC -fsanitize=undefined -fno-sanitize-recover=all)
endif()


if(TSAN OR ASAN OR UBSAN)
# no-omit-frame-pointer and no-optimize-sibling-calls provide better stack traces
target_compile_options(${PROJECT_NAME} PUBLIC -fno-omit-frame-pointer -fno-optimize-sibling-calls)
endif()
Expand Down
5 changes: 3 additions & 2 deletions tests/testlib/s2n_key_schedule_testlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ S2N_RESULT s2n_connection_set_test_transcript_hash(struct s2n_connection *conn,
message_type_t message_type, const struct s2n_blob *digest)
{
RESULT_GUARD(s2n_connection_set_test_message_type(conn, message_type));
conn->handshake.handshake_type = conn->handshake.handshake_type & NEGOTIATED;
conn->handshake.handshake_type &= NEGOTIATED;
RESULT_ENSURE_EQ(s2n_conn_get_current_message_type(conn), message_type);
RESULT_CHECKED_MEMCPY(conn->handshake.hashes->transcript_hash_digest,
digest->data, digest->size);
Expand Down Expand Up @@ -59,7 +59,8 @@ S2N_RESULT s2n_connection_set_test_master_secret(struct s2n_connection *conn,
return S2N_RESULT_OK;
}

S2N_RESULT s2n_connection_set_test_message_type(struct s2n_connection *conn, message_type_t expected_message_type) {
S2N_RESULT s2n_connection_set_test_message_type(struct s2n_connection *conn, message_type_t expected_message_type)
{
/* scan over all handshake types until the desired message type is found */
for (uint32_t handshake = 0; handshake < S2N_HANDSHAKES_COUNT; handshake++) {
for (int message = 0; message < S2N_MAX_HANDSHAKE_LENGTH; message++) {
Expand Down
4 changes: 2 additions & 2 deletions tls/s2n_handshake.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#define TLS_MESSAGE_HASH 254

/* Maximum number of messages in a handshake */
#define S2N_MAX_HANDSHAKE_LENGTH 32
#define S2N_MAX_HANDSHAKE_LENGTH 32

/* This is the list of message types that we support */
typedef enum {
Expand Down Expand Up @@ -89,7 +89,7 @@ typedef enum {
* starts off on the initial enum, which indicates we're using
* the TLS12 state machine. Once the handshake version is determined
* the enum is set to either the TLS12 or TLS13 state machine.
* This works because the initial entries in both the TLS12 and
* This works because the initial entries in both the TLS12 and
* TLS13 state machines are the same. */
typedef enum {
S2N_STATE_MACHINE_INITIAL = 0,
Expand Down

0 comments on commit 65c06aa

Please sign in to comment.