Skip to content

Commit cd0bf42

Browse files
committed
fix c related integer issues
1 parent 57e376a commit cd0bf42

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

openssl/src/asn1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ impl Asn1Time {
331331
}
332332

333333
/// Creates a new time on specified interval in seconds from now
334-
pub fn seconds_from_now(seconds: i64) -> Result<Asn1Time, ErrorStack> {
334+
pub fn seconds_from_now(seconds: c_long) -> Result<Asn1Time, ErrorStack> {
335335
Self::from_period(seconds)
336336
}
337337

openssl/src/x509/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,10 @@ impl X509Crl {
18521852
pub fn new(issuer_cert: &X509) -> Result<Self, ErrorStack> {
18531853
unsafe {
18541854
let crl = cvt_p(ffi::X509_CRL_new())?;
1855-
cvt(ffi::X509_CRL_set_version(crl, issuer_cert.version() as i64))?;
1855+
cvt(ffi::X509_CRL_set_version(
1856+
crl,
1857+
issuer_cert.version() as c_long,
1858+
))?;
18561859
cvt(ffi::X509_CRL_set_issuer_name(
18571860
crl,
18581861
issuer_cert.issuer_name().as_ptr(),
@@ -1868,7 +1871,7 @@ impl X509Crl {
18681871

18691872
/// use a negative value to set a time before 'now'
18701873
pub fn set_last_update(&mut self, seconds_from_now: Option<i32>) -> Result<(), ErrorStack> {
1871-
let time = Asn1Time::seconds_from_now(seconds_from_now.unwrap_or(0) as i64)?;
1874+
let time = Asn1Time::seconds_from_now(seconds_from_now.unwrap_or(0) as c_long)?;
18721875
unsafe { cvt(ffi::X509_CRL_set1_lastUpdate(self.as_ptr(), time.as_ptr())).map(|_| ()) }
18731876
}
18741877

@@ -1877,7 +1880,7 @@ impl X509Crl {
18771880
unsafe {
18781881
cvt(ffi::X509_CRL_set1_nextUpdate(
18791882
self.as_ptr(),
1880-
Asn1Time::seconds_from_now(seconds_from_now.into())?.as_ptr(),
1883+
Asn1Time::seconds_from_now(seconds_from_now as c_long)?.as_ptr(),
18811884
))
18821885
.map(|_| ())
18831886
}
@@ -1939,7 +1942,8 @@ impl X509Crl {
19391942
ffi::NID_crl_number,
19401943
std::mem::transmute(value.as_ptr()),
19411944
0,
1942-
ffi::X509V3_ADD_REPLACE,
1945+
#[allow(clippy::useless_conversion)]
1946+
ffi::X509V3_ADD_REPLACE.try_into().expect("This is an openssl flag and should therefore always fit into the expected integer type"),
19431947
))
19441948
.map(|_| ())
19451949
}

0 commit comments

Comments
 (0)