-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix lifetime errors in asn1.rs
with gil-refs
disabled
#10778
Conversation
// SAFETY: `PyBackedBytes`'s data is on the heap, so as long as it's not mutated, the | ||
// slice returned by `deref` remains valid. |
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.
bytes
are immutable in python, so the comment here should say that, not that it's fine as long as it's not mutated.
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.
fixed
src/rust/src/x509/extensions.rs
Outdated
@@ -52,9 +52,13 @@ pub(crate) fn encode_authority_key_identifier<'a>( | |||
} else { | |||
None | |||
}; | |||
let ka = cryptography_keepalive::KeepAlive::new(); |
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.
I don't think this is needed, you just need to change the scope of the serial_bytes
local to be function, rather than block.
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.
yes, fixed!
Should be good to rebase |
src/rust/src/x509/extensions.rs
Outdated
@@ -52,10 +53,11 @@ pub(crate) fn encode_authority_key_identifier<'a>( | |||
} else { | |||
None | |||
}; | |||
let serial_bytes: PyBackedBytes; |
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.
let serial_bytes: PyBackedBytes; | |
let serial_bytes; |
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.
fixed
src/rust/src/x509/ocsp_req.rs
Outdated
@@ -188,7 +189,8 @@ fn create_ocsp_request( | |||
(issuer_name_hash, issuer_key_hash, py_serial, py_hash) = builder | |||
.getattr(pyo3::intern!(py, "_request_hash"))? | |||
.extract()?; | |||
let serial_number = asn1::BigInt::new(py_uint_to_big_endian_bytes(py, py_serial)?).unwrap(); | |||
let serial_number_bytes = ka.add(py_uint_to_big_endian_bytes(py, py_serial)?); |
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.
I don't think a ka
is needed here. Can just do the scoping trick.
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.
good catch, fixed
723c628
to
a9519bc
Compare
Co-authored-by: Alex Gaynor <[email protected]>
Part of #10676
This should be merged after the keepalive PR is merged
Fixes all of the lifetime errors in
asn1.rs
, changing a return type ofpy_uint_to_big_endian_bytes
from&'p [u8]
toPyBackedBytes
.It uses the new
keepalive
in the places where thePyBackedBytes
object is borrowed for longer than its lifetime.cc @alex @reaperhulk