Skip to content
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

cipher: make output buffer String independent #824

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Dec 10, 2024

OpenSSL::Cipher#update accepts a String as the second argument to be used as the output buffer. The buffer must be directly writable, in other words, it must not be frozen and not a shared string.

rb_str_resize() does not make the String independent if the String already has the intended length. Use the rb_str_modify() family instead to check it.

Fixes: https://bugs.ruby-lang.org/issues/20937

OpenSSL::Cipher#update accepts a String as the second argument to be
used as the output buffer. The buffer must be directly writable, in
other words, it must not be frozen and not a shared string.

rb_str_resize() does not make the String independent if the String
already has the intended length. Use the rb_str_modify() family instead
to check it.

Fixes: https://bugs.ruby-lang.org/issues/20937
@rhenium rhenium force-pushed the ky/cipher-update-make-buffer-independent branch from 44c77ca to 1de3b80 Compare December 10, 2024 15:43
Likewise, OpenSSL::Digest#finish needs to make the output buffer
independent before writing to it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant