Skip to content

rustls_error: correct output buffer length handling #551

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

Merged
merged 2 commits into from
Mar 22, 2025
Merged

Conversation

ctz
Copy link
Member

@ctz ctz commented Mar 22, 2025

This function does not need to keep an output buffer byte spare to zero-terminate the string, as it doesn't terminate the output. So don't do that.

As an effect, this fixes the integer underflow followed by buffer overflow for rustls_error with an empty output buffer. test_rustls_error_into_empty_buffer is a regression test for that case.

(found while reviewing a use of this function in curl)

ctz added 2 commits March 22, 2025 13:48
This function does not need to keep an output buffer byte
spare to zero-terminate the string, as it doesn't terminate
the output.  So don't do that.

As an effect, this fixes the integer underflow followed by
buffer overflow for `rustls_error` with an empty output buffer.
`test_rustls_error_into_empty_buffer` is a regression test for
that case.
Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Good catch 👍

@cpu cpu mentioned this pull request Mar 22, 2025
21 tasks
@ctz ctz merged commit 32adae5 into main Mar 22, 2025
92 checks passed
@ctz ctz deleted the jbp-error-len-handling branch March 22, 2025 16:35
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.

3 participants