Skip to content

Conversation

@rizlik
Copy link
Contributor

@rizlik rizlik commented Oct 22, 2025

Description

The internal buffer index pointer wasn't incremented in case of error inside _Dtls13HandshakeRecv, causing an hangs.

Fixes zd#20686

Added tests to increase coverage from non-blocking I/O.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a handshake hang issue in DTLS 1.3 that occurred when a WANT_WRITE I/O error was encountered. The core fix ensures the internal buffer index pointer is updated before error handling, preventing infinite loops. Additionally, the PR corrects bugs in test infrastructure where client/server force-want-write flags were swapped, and adds comprehensive test coverage for non-blocking I/O scenarios.

Key Changes:

  • Moved buffer index update in _Dtls13HandshakeRecv to occur before error checking
  • Fixed swapped client/server forceWantWrite references in test I/O callbacks
  • Added two new test cases to verify proper handling of WANT_WRITE conditions during DTLS 1.3 handshakes

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/dtls13.c Fixes buffer index update timing to prevent handshake hangs on WANT_WRITE errors
tests/utils.c Corrects swapped client/server force-want-write flag assignments in I/O callback
tests/api/test_dtls.h Declares two new test functions for DTLS 1.3 WANT_WRITE scenarios
tests/api/test_dtls.c Implements comprehensive tests for HRR and every-write WANT_WRITE cases
tests/api.c Fixes incorrect side parameter in test_memio_simulate_want_write calls

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@devin-ai-integration
Copy link
Contributor

🛟 Devin Lifeguard found 1 likely issues in this PR

  • pointer-null-check snippet: Guard the write with a null-check, e.g., if (processedSize != NULL) *processedSize = idx;, ensuring no dereference occurs when the pointer is NULL.

@rizlik
please take a look at the above issues which Devin flagged. Devin will not fix these issues automatically.

@rizlik
Copy link
Contributor Author

rizlik commented Oct 23, 2025

retest this please

@julek-wolfssl julek-wolfssl self-assigned this Oct 24, 2025
@rizlik rizlik force-pushed the dtls13_want_write_fix branch from 68a43c1 to 292aee5 Compare October 27, 2025 14:42
@rizlik
Copy link
Contributor Author

rizlik commented Oct 28, 2025

retest this please
SSL_accept error -501, can't match cipher suite

@rizlik rizlik requested a review from julek-wolfssl October 29, 2025 13:18
@rizlik rizlik assigned julek-wolfssl and unassigned rizlik Oct 29, 2025
@rizlik rizlik force-pushed the dtls13_want_write_fix branch from 292aee5 to 27fff1e Compare October 29, 2025 15:58
@rizlik rizlik assigned julek-wolfssl and unassigned rizlik Oct 29, 2025
@julek-wolfssl julek-wolfssl removed their assignment Nov 3, 2025
@rizlik rizlik force-pushed the dtls13_want_write_fix branch from 27fff1e to 33be31a Compare November 3, 2025 12:44
@rizlik rizlik requested a review from julek-wolfssl November 3, 2025 13:23
@rizlik rizlik assigned julek-wolfssl and unassigned rizlik Nov 3, 2025
@SparkiDev SparkiDev self-assigned this Nov 5, 2025
@SparkiDev SparkiDev merged commit 97e9fa0 into wolfSSL:master Nov 5, 2025
261 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants