Bug 1987422 - osclientcerts: null-check before wrapping CF objects a=RyanVM DONTBUILD
Original Revision: https://phabricator.services.mozilla.com/D264138 Differential Revision: https://phabricator.services.mozilla.com/D267026
This commit is contained in:
committed by
rvandermeulen@mozilla.com
parent
e2d46879fa
commit
f51bb96e4e
@@ -226,6 +226,9 @@ fn sec_key_create_signature(
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
if signature.is_null() {
|
if signature.is_null() {
|
||||||
|
if error.is_null() {
|
||||||
|
return Err(error_here!(ErrorType::ExternalError));
|
||||||
|
}
|
||||||
let error = unsafe { CFError::wrap_under_create_rule(error) };
|
let error = unsafe { CFError::wrap_under_create_rule(error) };
|
||||||
return Err(error_here!(
|
return Err(error_here!(
|
||||||
ErrorType::ExternalError,
|
ErrorType::ExternalError,
|
||||||
@@ -235,8 +238,12 @@ fn sec_key_create_signature(
|
|||||||
Ok(unsafe { CFData::wrap_under_create_rule(signature) })
|
Ok(unsafe { CFData::wrap_under_create_rule(signature) })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sec_key_copy_attributes<T: TCFType>(key: &SecKey) -> CFDictionary<CFString, T> {
|
fn sec_key_copy_attributes<T: TCFType>(key: &SecKey) -> Result<CFDictionary<CFString, T>, Error> {
|
||||||
unsafe { CFDictionary::wrap_under_create_rule(SecKeyCopyAttributes(key.as_concrete_TypeRef())) }
|
let attributes = unsafe { SecKeyCopyAttributes(key.as_concrete_TypeRef()) };
|
||||||
|
if attributes.is_null() {
|
||||||
|
return Err(error_here!(ErrorType::ExternalError));
|
||||||
|
}
|
||||||
|
Ok(unsafe { CFDictionary::wrap_under_create_rule(attributes) })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sec_key_copy_external_representation(key: &SecKey) -> Result<CFData, Error> {
|
fn sec_key_copy_external_representation(key: &SecKey) -> Result<CFData, Error> {
|
||||||
@@ -244,6 +251,9 @@ fn sec_key_copy_external_representation(key: &SecKey) -> Result<CFData, Error> {
|
|||||||
let representation =
|
let representation =
|
||||||
unsafe { SecKeyCopyExternalRepresentation(key.as_concrete_TypeRef(), &mut error) };
|
unsafe { SecKeyCopyExternalRepresentation(key.as_concrete_TypeRef(), &mut error) };
|
||||||
if representation.is_null() {
|
if representation.is_null() {
|
||||||
|
if error.is_null() {
|
||||||
|
return Err(error_here!(ErrorType::ExternalError));
|
||||||
|
}
|
||||||
let error = unsafe { CFError::wrap_under_create_rule(error) };
|
let error = unsafe { CFError::wrap_under_create_rule(error) };
|
||||||
return Err(error_here!(
|
return Err(error_here!(
|
||||||
ErrorType::ExternalError,
|
ErrorType::ExternalError,
|
||||||
@@ -814,7 +824,7 @@ impl Sign for Key {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_key_attribute<T: TCFType + Clone>(key: &SecKey, attr: CFStringRef) -> Result<T, Error> {
|
fn get_key_attribute<T: TCFType + Clone>(key: &SecKey, attr: CFStringRef) -> Result<T, Error> {
|
||||||
let attributes: CFDictionary<CFString, T> = sec_key_copy_attributes(key);
|
let attributes: CFDictionary<CFString, T> = sec_key_copy_attributes(key)?;
|
||||||
match attributes.find(attr as *const _) {
|
match attributes.find(attr as *const _) {
|
||||||
Some(value) => Ok((*value).clone()),
|
Some(value) => Ok((*value).clone()),
|
||||||
None => Err(error_here!(ErrorType::ExternalError)),
|
None => Err(error_here!(ErrorType::ExternalError)),
|
||||||
|
|||||||
Reference in New Issue
Block a user