Skip to content

Fix SSL.write silently losing data when encryption fails - #139

Merged
SeanTAllen merged 1 commit into
mainfrom
fix-ssl-write-return-value
Aug 2, 2026
Merged

Fix SSL.write silently losing data when encryption fails#139
SeanTAllen merged 1 commit into
mainfrom
fix-ssl-write-return-value

Conversation

@SeanTAllen

Copy link
Copy Markdown
Member

SSL.write discarded SSL_write's return value, so it reported success even when the call encrypted nothing. A TLS 1.2 peer that started a renegotiation hit this: the session was still SSLReady, SSL_write returned SSL_ERROR_WANT_READ, and the payload was gone with no signal to the caller.

write now checks SSL_write's return value and raises on failure. Fatal errors (SSL_ERROR_SSL, SSL_ERROR_SYSCALL, SSL_ERROR_ZERO_RETURN) set _state = SSLError; a transient SSL_ERROR_WANT_READ raises without changing state. The error dispatch mirrors read().

All three callers in SSLConnection already wrap write in try/else, so no caller changes are needed.

Closes #122

SSL.write discarded SSL_write's return value, so it reported success
when it encrypted nothing. write now checks the return, distinguishes
fatal from transient errors, and raises on failure.

Closes #122
@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Aug 2, 2026
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Aug 2, 2026
@SeanTAllen
SeanTAllen merged commit c3fdfd2 into main Aug 2, 2026
16 checks passed
@SeanTAllen
SeanTAllen deleted the fix-ssl-write-return-value branch August 2, 2026 02:01
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Aug 2, 2026
github-actions Bot pushed a commit that referenced this pull request Aug 2, 2026
github-actions Bot pushed a commit that referenced this pull request Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSL.write reports success when SSL_write encrypted nothing

2 participants