-
Notifications
You must be signed in to change notification settings - Fork 132
Rework memory BIOs and implement BIO_seek (2nd try) #2433
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
base: main
Are you sure you want to change the base?
Conversation
### Issues: Resolves #CryptoAlg-3111 ### Description of changes: This PR creates a wrapper around `BUF_MEM` and adds a new field `off` to indicate the current offset of the read pointer. This enables us to implement `BIO_seek`, which is also in this PR. ### Testing: Unit tests are modified and added to cover more test cases. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
|
||
BIO *BIO_new_mem_buf(const void *buf, ossl_ssize_t len) { | ||
BIO *ret; | ||
BUF_MEM *b; | ||
const size_t size = len < 0 ? strlen((char *)buf) : (size_t)len; | ||
BIO_BUF_MEM *bbm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'bbm' is not initialized [cppcoreguidelines-init-variables]
BIO_BUF_MEM *bbm; | |
BIO_BUF_MEM *bbm = NULL; |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2433 +/- ##
==========================================
+ Coverage 78.88% 78.89% +0.01%
==========================================
Files 621 621
Lines 108547 108671 +124
Branches 15406 15420 +14
==========================================
+ Hits 85623 85738 +115
- Misses 22256 22261 +5
- Partials 668 672 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Issues:
Resolves #CryptoAlg-3111
Description of changes:
Same as #2380.
Fixed the state bug that was causing Ruby failures. The failures came from
BIO_reset
, which tries to "rewind" the R/O buffer to its original state. The old implementation only works when the buffer pointer and read pointer are aligned. But in the new memory BIO, this is not always the case. The buffer pointer (b->data
) does not need to align with the read pointer (since we can have a positivebbm->read_off
). Our tests didn't cover this because the buffer pointer was synced with read pointer after every test case.Testing:
Added tests for
BIO_reset
andBIO_seek
functions that attempt to rewind the buffer internally. The tests cover both cases -- when buffer pointer and read pointer are synced and when they are not.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.