From cd0bf42b96949b12ed008f0a39ab8ede6c913d36 Mon Sep 17 00:00:00 2001 From: Georg Weisert Date: Sat, 17 Feb 2024 10:34:04 +0100 Subject: [PATCH] fix c related integer issues --- openssl/src/asn1.rs | 2 +- openssl/src/x509/mod.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/openssl/src/asn1.rs b/openssl/src/asn1.rs index 648755ff9..12e0e2839 100644 --- a/openssl/src/asn1.rs +++ b/openssl/src/asn1.rs @@ -331,7 +331,7 @@ impl Asn1Time { } /// Creates a new time on specified interval in seconds from now - pub fn seconds_from_now(seconds: i64) -> Result { + pub fn seconds_from_now(seconds: c_long) -> Result { Self::from_period(seconds) } diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs index 5cc9039fc..188a7e5be 100644 --- a/openssl/src/x509/mod.rs +++ b/openssl/src/x509/mod.rs @@ -1852,7 +1852,10 @@ impl X509Crl { pub fn new(issuer_cert: &X509) -> Result { unsafe { let crl = cvt_p(ffi::X509_CRL_new())?; - cvt(ffi::X509_CRL_set_version(crl, issuer_cert.version() as i64))?; + cvt(ffi::X509_CRL_set_version( + crl, + issuer_cert.version() as c_long, + ))?; cvt(ffi::X509_CRL_set_issuer_name( crl, issuer_cert.issuer_name().as_ptr(), @@ -1868,7 +1871,7 @@ impl X509Crl { /// use a negative value to set a time before 'now' pub fn set_last_update(&mut self, seconds_from_now: Option) -> Result<(), ErrorStack> { - let time = Asn1Time::seconds_from_now(seconds_from_now.unwrap_or(0) as i64)?; + let time = Asn1Time::seconds_from_now(seconds_from_now.unwrap_or(0) as c_long)?; unsafe { cvt(ffi::X509_CRL_set1_lastUpdate(self.as_ptr(), time.as_ptr())).map(|_| ()) } } @@ -1877,7 +1880,7 @@ impl X509Crl { unsafe { cvt(ffi::X509_CRL_set1_nextUpdate( self.as_ptr(), - Asn1Time::seconds_from_now(seconds_from_now.into())?.as_ptr(), + Asn1Time::seconds_from_now(seconds_from_now as c_long)?.as_ptr(), )) .map(|_| ()) } @@ -1939,7 +1942,8 @@ impl X509Crl { ffi::NID_crl_number, std::mem::transmute(value.as_ptr()), 0, - ffi::X509V3_ADD_REPLACE, + #[allow(clippy::useless_conversion)] + ffi::X509V3_ADD_REPLACE.try_into().expect("This is an openssl flag and should therefore always fit into the expected integer type"), )) .map(|_| ()) }