Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: grep for S2N_RESULT_ERR without setting s2n_errno #4534

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions codebuild/bin/grep_simple_mistakes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ for file in $S2N_FILES_ASSERT_RETURN; do
RESULT_NEGATIVE_ONE=`grep -rn 'return -1;' $file`
RESULT_S2N_ERR=`grep -rn 'return S2N_ERR*' $file`
RESULT_S2N_FAIL=`grep -rn 'return S2N_FAIL*' $file`
RESULT_S2N_RESULT_ERR=`grep -rn 'return S2N_RESULT_ERR*' $file`

if [ "${#RESULT_NEGATIVE_ONE}" != "0" ]; then
FAILED=1
Expand All @@ -88,6 +89,10 @@ for file in $S2N_FILES_ASSERT_RETURN; do
FAILED=1
printf "\e[1;34mGrep for 'return S2N_FAIL*' check failed in $file:\e[0m\n$RESULT_S2N_FAIL\n\n"
fi
if [ "${#RESULT_S2N_RESULT_ERR}" != "0" ]; then
FAILED=1
printf "\e[1;34mGrep for 'return S2N_RESULT_ERR*' check failed in $file:\e[0m\n$RESULT_S2N_RESULT_ERR\n\n"
fi
done

#############################################
Expand Down
7 changes: 2 additions & 5 deletions tls/s2n_async_pkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static S2N_RESULT s2n_async_get_actions(s2n_async_pkey_op_type type, const struc
/* No default for compiler warnings */
}

return S2N_RESULT_ERROR;
RESULT_BAIL(S2N_ERR_SAFETY);
}

static S2N_RESULT s2n_async_pkey_op_allocate(struct s2n_async_pkey_op **op)
Expand All @@ -138,10 +138,7 @@ static S2N_RESULT s2n_async_pkey_op_allocate(struct s2n_async_pkey_op **op)
RESULT_GUARD_POSIX(s2n_blob_zero(&mem));

*op = (void *) mem.data;
if (s2n_blob_init(&mem, NULL, 0) != S2N_SUCCESS) {
*op = NULL;
return S2N_RESULT_ERROR;
}
ZERO_TO_DISABLE_DEFER_CLEANUP(mem);
return S2N_RESULT_OK;
}

Expand Down
13 changes: 7 additions & 6 deletions tls/s2n_early_data_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ S2N_RESULT s2n_send_early_data_impl(struct s2n_connection *conn, const uint8_t *
int negotiate_result = s2n_negotiate(conn, blocked);
if (negotiate_result < S2N_SUCCESS) {
if (s2n_error_get_type(s2n_errno) != S2N_ERR_T_BLOCKED) {
return S2N_RESULT_ERROR;
RESULT_GUARD_POSIX(negotiate_result);
} else if (*blocked != S2N_BLOCKED_ON_EARLY_DATA && *blocked != S2N_BLOCKED_ON_READ) {
return S2N_RESULT_ERROR;
RESULT_GUARD_POSIX(negotiate_result);
}
}
/* Save the error status for later */
Expand Down Expand Up @@ -239,14 +239,15 @@ S2N_RESULT s2n_recv_early_data_impl(struct s2n_connection *conn, uint8_t *data,
return S2N_RESULT_OK;
}

while (s2n_negotiate(conn, blocked) < S2N_SUCCESS) {
int negotiate_result = S2N_SUCCESS;
while ((negotiate_result = s2n_negotiate(conn, blocked)) != S2N_SUCCESS) {
if (s2n_error_get_type(s2n_errno) != S2N_ERR_T_BLOCKED) {
return S2N_RESULT_ERROR;
RESULT_GUARD_POSIX(negotiate_result);
} else if (max_data_len <= *data_received) {
return S2N_RESULT_ERROR;
RESULT_GUARD_POSIX(negotiate_result);
} else if (*blocked != S2N_BLOCKED_ON_EARLY_DATA) {
if (s2n_early_data_can_continue(conn)) {
return S2N_RESULT_ERROR;
RESULT_GUARD_POSIX(negotiate_result);
} else {
*blocked = S2N_NOT_BLOCKED;
return S2N_RESULT_OK;
Expand Down
Loading