Introduce SafeDbt to handle Dbt with free or memory_cleanse raii-style#14268
Conversation
|
promag
left a comment
There was a problem hiding this comment.
utACK 985892e.
nit, first commit kind of unrelated — could mention the dead code cleanup in the PR description.
|
utACK 985892e5aa75b76f71a354c8d835d7729048cccc |
|
utACK 985892e Style-nit: the developer notes say "No indentation for First commit is unrelated as promag said, but a nice cleanup, the last use of |
SafeDbt to handle Dbt with free or memory_cleanse raii-style
SafeDbt to handle Dbt with free or memory_cleanse raii-style|
Ok just pushed some significant changes:
|
This provides additional exception-safety and case handling for the proper freeing of the associated buffers.
|
Appveyor failure looks unrelated. |
|
utACK 1a9f9f7 |
| return m_dbt.get_size(); | ||
| } | ||
|
|
||
| BerkeleyBatch::SafeDbt::operator Dbt*() |
There was a problem hiding this comment.
it's returning a mutable pointer to the internal structure, I don't think it'd make sense to make the method const (unless you mean it should return a const* pointer too, but that's likely not good enough for the BDB functions)
|
utACK 1a9f9f7 |
| { | ||
| if (m_dbt.get_data() != nullptr) { | ||
| // Clear memory, e.g. in case it was a private key | ||
| memory_cleanse(m_dbt.get_data(), m_dbt.get_size()); |
There was a problem hiding this comment.
This changes behavior: in the case of Write it was also cleansing the dtabase key, now it no longer is.
Not sure if this is necessary, I don't think the database keys ever contain sensitive information, but it should be noted.
There was a problem hiding this comment.
I believe it is cleansing the key - if you're referring to the cleansing here:
https://github.com/bitcoin/bitcoin/pull/14268/files#diff-c557c8e6d496041acccfd8ac4e3db625L257
Then the key and value are separate SafeDbt objects, with each managing/cleansing its own data:
https://github.com/bitcoin/bitcoin/pull/14268/files#diff-c557c8e6d496041acccfd8ac4e3db625R258
https://github.com/bitcoin/bitcoin/pull/14268/files#diff-c557c8e6d496041acccfd8ac4e3db625R264
|
Added another commit:
Separate for easier review, can squash. |
If we're constructing the SafeDbt without provided data, it is always malloced, so that is the case we expose. Also run clang-format.
|
Appveyor failure looks unrelated: "ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine" |
…anse raii-style 4a86a0a Make SafeDbt DB_DBT_MALLOC on default initialization (Ben Woosley) 1a9f9f7 Introduce SafeDbt to handle DB_DBT_MALLOC raii-style (Ben Woosley) 951a44e Drop unused setRange arg to BerkeleyBatch::ReadAtCursor (Ben Woosley) Pull request description: This provides additional exception-safety and case handling for the proper freeing of the associated buffers. Tree-SHA512: a038d728290cdb3905e7d881608052a6675b6425729ceaf7cfe69a6e91c2ee293cdb01e4b695a20963459ffdd9d4a1f9a08b3c07b1b5ba1aa8590a8149f686db
Summary: bitcoin/bitcoin@951a44e --- Partial backport of Core [[bitcoin/bitcoin#14268 | PR14268]] Test Plan: ninja check check-functional Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D7321
Summary: This provides additional exception-safety and case handling for the proper freeing of the associated buffers. bitcoin/bitcoin@1a9f9f7 --- Depends on D7321 Partial backport of Core [[bitcoin/bitcoin#14268 | PR14268]] Test Plan: ninja check check-functional Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D7322
Summary: If we're constructing the SafeDbt without provided data, it is always malloced, so that is the case we expose. Also run clang-format. bitcoin/bitcoin@4a86a0a --- Depends on D7322 Concludes backport of Core [[bitcoin/bitcoin#14268 | PR14268]] Test Plan: ninja check check-functional Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D7323
…ory_cleanse raii-style 4a86a0a Make SafeDbt DB_DBT_MALLOC on default initialization (Ben Woosley) 1a9f9f7 Introduce SafeDbt to handle DB_DBT_MALLOC raii-style (Ben Woosley) 951a44e Drop unused setRange arg to BerkeleyBatch::ReadAtCursor (Ben Woosley) Pull request description: This provides additional exception-safety and case handling for the proper freeing of the associated buffers. Tree-SHA512: a038d728290cdb3905e7d881608052a6675b6425729ceaf7cfe69a6e91c2ee293cdb01e4b695a20963459ffdd9d4a1f9a08b3c07b1b5ba1aa8590a8149f686db
…94_14969 Merge 0.18 PRs: bitcoin#14268, bitcoin#15408, bitcoin#14094, bitcoin#14935 and bitcoin#14969
This provides additional exception-safety and case handling for the proper
freeing of the associated buffers.