Cast correctly c_char raw pointers (fixes build on ARM #314)
This commit is contained in:
parent
1d09eec734
commit
f54af75eb7
|
|
@ -89,7 +89,7 @@ impl BigNum {
|
||||||
pub fn from_dec_str(s: &str) -> Result<BigNum, SslError> {
|
pub fn from_dec_str(s: &str) -> Result<BigNum, SslError> {
|
||||||
BigNum::new().and_then(|v| unsafe {
|
BigNum::new().and_then(|v| unsafe {
|
||||||
let c_str = CString::new(s.as_bytes()).unwrap();
|
let c_str = CString::new(s.as_bytes()).unwrap();
|
||||||
try_ssl!(ffi::BN_dec2bn(v.raw_ptr(), c_str.as_ptr()));
|
try_ssl!(ffi::BN_dec2bn(v.raw_ptr(), c_str.as_ptr() as *const _));
|
||||||
Ok(v)
|
Ok(v)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +97,7 @@ impl BigNum {
|
||||||
pub fn from_hex_str(s: &str) -> Result<BigNum, SslError> {
|
pub fn from_hex_str(s: &str) -> Result<BigNum, SslError> {
|
||||||
BigNum::new().and_then(|v| unsafe {
|
BigNum::new().and_then(|v| unsafe {
|
||||||
let c_str = CString::new(s.as_bytes()).unwrap();
|
let c_str = CString::new(s.as_bytes()).unwrap();
|
||||||
try_ssl!(ffi::BN_hex2bn(v.raw_ptr(), c_str.as_ptr()));
|
try_ssl!(ffi::BN_hex2bn(v.raw_ptr(), c_str.as_ptr() as *const _));
|
||||||
Ok(v)
|
Ok(v)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -421,7 +421,7 @@ impl BigNum {
|
||||||
unsafe {
|
unsafe {
|
||||||
let buf = ffi::BN_bn2dec(self.raw());
|
let buf = ffi::BN_bn2dec(self.raw());
|
||||||
assert!(!buf.is_null());
|
assert!(!buf.is_null());
|
||||||
let str = String::from_utf8(CStr::from_ptr(buf).to_bytes().to_vec()).unwrap();
|
let str = String::from_utf8(CStr::from_ptr(buf as *const _).to_bytes().to_vec()).unwrap();
|
||||||
ffi::CRYPTO_free(buf as *mut c_void);
|
ffi::CRYPTO_free(buf as *mut c_void);
|
||||||
str
|
str
|
||||||
}
|
}
|
||||||
|
|
@ -431,7 +431,7 @@ impl BigNum {
|
||||||
unsafe {
|
unsafe {
|
||||||
let buf = ffi::BN_bn2hex(self.raw());
|
let buf = ffi::BN_bn2hex(self.raw());
|
||||||
assert!(!buf.is_null());
|
assert!(!buf.is_null());
|
||||||
let str = String::from_utf8(CStr::from_ptr(buf).to_bytes().to_vec()).unwrap();
|
let str = String::from_utf8(CStr::from_ptr(buf as *const _).to_bytes().to_vec()).unwrap();
|
||||||
ffi::CRYPTO_free(buf as *mut c_void);
|
ffi::CRYPTO_free(buf as *mut c_void);
|
||||||
str
|
str
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,21 +117,24 @@ pub enum OpensslError {
|
||||||
|
|
||||||
fn get_lib(err: c_ulong) -> String {
|
fn get_lib(err: c_ulong) -> String {
|
||||||
unsafe {
|
unsafe {
|
||||||
let bytes = CStr::from_ptr(ffi::ERR_lib_error_string(err)).to_bytes().to_vec();
|
let cstr = ffi::ERR_lib_error_string(err);
|
||||||
|
let bytes = CStr::from_ptr(cstr as *const _).to_bytes().to_vec();
|
||||||
String::from_utf8(bytes).unwrap()
|
String::from_utf8(bytes).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_func(err: c_ulong) -> String {
|
fn get_func(err: c_ulong) -> String {
|
||||||
unsafe {
|
unsafe {
|
||||||
let bytes = CStr::from_ptr(ffi::ERR_func_error_string(err)).to_bytes().to_vec();
|
let cstr = ffi::ERR_func_error_string(err);
|
||||||
|
let bytes = CStr::from_ptr(cstr as *const _).to_bytes().to_vec();
|
||||||
String::from_utf8(bytes).unwrap()
|
String::from_utf8(bytes).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_reason(err: c_ulong) -> String {
|
fn get_reason(err: c_ulong) -> String {
|
||||||
unsafe {
|
unsafe {
|
||||||
let bytes = CStr::from_ptr(ffi::ERR_reason_error_string(err)).to_bytes().to_vec();
|
let cstr = ffi::ERR_reason_error_string(err);
|
||||||
|
let bytes = CStr::from_ptr(cstr as *const _).to_bytes().to_vec();
|
||||||
String::from_utf8(bytes).unwrap()
|
String::from_utf8(bytes).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -510,7 +510,7 @@ impl SslContext {
|
||||||
let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
|
let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
|
||||||
wrap_ssl_result(
|
wrap_ssl_result(
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::SSL_CTX_load_verify_locations(self.ctx, file.as_ptr(), ptr::null())
|
ffi::SSL_CTX_load_verify_locations(self.ctx, file.as_ptr() as *const _, ptr::null())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -520,7 +520,7 @@ impl SslContext {
|
||||||
let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
|
let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
|
||||||
wrap_ssl_result(
|
wrap_ssl_result(
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::SSL_CTX_use_certificate_file(self.ctx, file.as_ptr(), file_type as c_int)
|
ffi::SSL_CTX_use_certificate_file(self.ctx, file.as_ptr() as *const _, file_type as c_int)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -530,7 +530,7 @@ impl SslContext {
|
||||||
let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
|
let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
|
||||||
wrap_ssl_result(
|
wrap_ssl_result(
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::SSL_CTX_use_certificate_chain_file(self.ctx, file.as_ptr(), file_type as c_int)
|
ffi::SSL_CTX_use_certificate_chain_file(self.ctx, file.as_ptr() as *const _, file_type as c_int)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -557,7 +557,7 @@ impl SslContext {
|
||||||
let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
|
let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
|
||||||
wrap_ssl_result(
|
wrap_ssl_result(
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::SSL_CTX_use_PrivateKey_file(self.ctx, file.as_ptr(), file_type as c_int)
|
ffi::SSL_CTX_use_PrivateKey_file(self.ctx, file.as_ptr() as *const _, file_type as c_int)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -581,7 +581,7 @@ impl SslContext {
|
||||||
wrap_ssl_result(
|
wrap_ssl_result(
|
||||||
unsafe {
|
unsafe {
|
||||||
let cipher_list = CString::new(cipher_list).unwrap();
|
let cipher_list = CString::new(cipher_list).unwrap();
|
||||||
ffi::SSL_CTX_set_cipher_list(self.ctx, cipher_list.as_ptr())
|
ffi::SSL_CTX_set_cipher_list(self.ctx, cipher_list.as_ptr() as *const _)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -768,7 +768,7 @@ impl Ssl {
|
||||||
pub fn state_string(&self) -> &'static str {
|
pub fn state_string(&self) -> &'static str {
|
||||||
let state = unsafe {
|
let state = unsafe {
|
||||||
let ptr = ffi::SSL_state_string(self.ssl);
|
let ptr = ffi::SSL_state_string(self.ssl);
|
||||||
CStr::from_ptr(ptr)
|
CStr::from_ptr(ptr as *const _)
|
||||||
};
|
};
|
||||||
|
|
||||||
str::from_utf8(state.to_bytes()).unwrap()
|
str::from_utf8(state.to_bytes()).unwrap()
|
||||||
|
|
@ -777,7 +777,7 @@ impl Ssl {
|
||||||
pub fn state_string_long(&self) -> &'static str {
|
pub fn state_string_long(&self) -> &'static str {
|
||||||
let state = unsafe {
|
let state = unsafe {
|
||||||
let ptr = ffi::SSL_state_string_long(self.ssl);
|
let ptr = ffi::SSL_state_string_long(self.ssl);
|
||||||
CStr::from_ptr(ptr)
|
CStr::from_ptr(ptr as *const _)
|
||||||
};
|
};
|
||||||
|
|
||||||
str::from_utf8(state.to_bytes()).unwrap()
|
str::from_utf8(state.to_bytes()).unwrap()
|
||||||
|
|
@ -786,7 +786,7 @@ impl Ssl {
|
||||||
/// Sets the host name to be used with SNI (Server Name Indication).
|
/// Sets the host name to be used with SNI (Server Name Indication).
|
||||||
pub fn set_hostname(&self, hostname: &str) -> Result<(), SslError> {
|
pub fn set_hostname(&self, hostname: &str) -> Result<(), SslError> {
|
||||||
let cstr = CString::new(hostname).unwrap();
|
let cstr = CString::new(hostname).unwrap();
|
||||||
let ret = unsafe { ffi_extras::SSL_set_tlsext_host_name(self.ssl, cstr.as_ptr()) };
|
let ret = unsafe { ffi_extras::SSL_set_tlsext_host_name(self.ssl, cstr.as_ptr() as *const _) };
|
||||||
|
|
||||||
// For this case, 0 indicates failure.
|
// For this case, 0 indicates failure.
|
||||||
if ret == 0 {
|
if ret == 0 {
|
||||||
|
|
@ -874,7 +874,7 @@ impl Ssl {
|
||||||
|
|
||||||
let meth = unsafe { ffi::SSL_COMP_get_name(ptr) };
|
let meth = unsafe { ffi::SSL_COMP_get_name(ptr) };
|
||||||
let s = unsafe {
|
let s = unsafe {
|
||||||
String::from_utf8(CStr::from_ptr(meth).to_bytes().to_vec()).unwrap()
|
String::from_utf8(CStr::from_ptr(meth as *const _).to_bytes().to_vec()).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(s)
|
Some(s)
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ impl Deref for SslString {
|
||||||
impl SslString {
|
impl SslString {
|
||||||
unsafe fn new(buf: *const c_char) -> SslString {
|
unsafe fn new(buf: *const c_char) -> SslString {
|
||||||
SslString {
|
SslString {
|
||||||
s: str::from_utf8(CStr::from_ptr(buf).to_bytes()).unwrap()
|
s: str::from_utf8(CStr::from_ptr(buf as *const _).to_bytes()).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -275,8 +275,8 @@ impl X509Generator {
|
||||||
lift_ssl!(unsafe {
|
lift_ssl!(unsafe {
|
||||||
let key = CString::new(key.as_bytes()).unwrap();
|
let key = CString::new(key.as_bytes()).unwrap();
|
||||||
let value = CString::new(value.as_bytes()).unwrap();
|
let value = CString::new(value.as_bytes()).unwrap();
|
||||||
ffi::X509_NAME_add_entry_by_txt(name, key.as_ptr(), ffi::MBSTRING_UTF8,
|
ffi::X509_NAME_add_entry_by_txt(name, key.as_ptr() as *const _, ffi::MBSTRING_UTF8,
|
||||||
value.as_ptr(), value_len, -1, 0)
|
value.as_ptr() as *const _, value_len, -1, 0)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue