Skip to content

Commit

Permalink
ci: grep for S2N_RESULT_ERR without setting s2n_errno
Browse files Browse the repository at this point in the history
  • Loading branch information
lrstewart committed May 2, 2024
1 parent f711736 commit acba53f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
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

0 comments on commit acba53f

Please sign in to comment.