Skip to content

Commit

Permalink
dtls: Increment sequence number in SendAlert
Browse files Browse the repository at this point in the history
  • Loading branch information
julek-wolfssl committed Jun 4, 2024
1 parent e428c28 commit ede8cde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -24894,6 +24894,11 @@ static int SendAlert_ex(WOLFSSL* ssl, int severity, int type)
#endif /* WOLFSSL_DTLS13 */
{
AddRecordHeader(output, ALERT_SIZE, alert, ssl, CUR_ORDER);
#ifdef WOLFSSL_DTLS
/* AddRecordHeader doesn't increment the seq number */
if (ssl->options.dtls)
DtlsSEQIncrement(ssl, CUR_ORDER);
#endif
}

output += RECORD_HEADER_SZ;
Expand Down
6 changes: 3 additions & 3 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -72699,7 +72699,7 @@ static int test_wolfSSL_SendUserCanceled(void)
struct test_memio_ctx test_ctx;
WOLFSSL_ALERT_HISTORY h;

printf("Testing %s", params[i].tls_version);
printf("Testing %s\n", params[i].tls_version);

XMEMSET(&h, 0, sizeof(h));
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
Expand All @@ -72719,8 +72719,8 @@ static int test_wolfSSL_SendUserCanceled(void)
/* Last alert will be close notify because user_canceled should be
* followed by a close_notify */
ExpectIntEQ(wolfSSL_get_alert_history(ssl_c, &h), WOLFSSL_SUCCESS);
AssertIntEQ(h.last_rx.code, close_notify);
AssertIntEQ(h.last_rx.level, alert_warning);
ExpectIntEQ(h.last_rx.code, close_notify);
ExpectIntEQ(h.last_rx.level, alert_warning);

wolfSSL_free(ssl_c);
wolfSSL_free(ssl_s);
Expand Down

0 comments on commit ede8cde

Please sign in to comment.