Skip to content

Commit 187ee6d

Browse files
nomickthillux
authored andcommitted
some style fixes
1 parent a7dc993 commit 187ee6d

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

openssl-sys/src/handwritten/x509_sbgp.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,16 @@ extern "C" {
7575
pub fn IPAddressOrRange_free(asi: *mut _IPAddressOrRange);
7676
}
7777

78-
pub fn X509v3_addr_get_afi(f: *mut _IPAddressFamily) -> c_int {
79-
unsafe {
80-
if f.is_null() {
78+
pub unsafe fn X509v3_addr_get_afi(f: *mut _IPAddressFamily) -> c_int {
79+
if f.is_null() {
80+
0
81+
} else {
82+
let d = (*f).addressFamily as *mut ASN1_STRING;
83+
if d.is_null() || ASN1_STRING_length(d) < 2 || ASN1_STRING_get0_data(d).is_null() {
8184
0
8285
} else {
83-
let d = (*f).addressFamily as *mut ASN1_STRING;
84-
if d.is_null() || ASN1_STRING_length(d) < 2 || ASN1_STRING_get0_data(d).is_null() {
85-
0
86-
} else {
87-
let raw = ASN1_STRING_get0_data(d);
88-
((*raw.offset(0) as i32) << 8) | *raw.offset(1) as i32
89-
}
86+
let raw = ASN1_STRING_get0_data(d);
87+
((*raw.offset(0) as i32) << 8) | *raw.offset(1) as i32
9088
}
9189
}
9290
}
@@ -142,7 +140,7 @@ fn addr_expand(addr: *mut u8, bs: *const ASN1_BIT_STRING, length: isize, fill: u
142140
}
143141

144142
// fill up bytes
145-
for i in (str_len as isize)..(length as isize) {
143+
for i in (str_len as isize)..length {
146144
*addr.offset(i) = fill;
147145
}
148146
}
@@ -157,11 +155,11 @@ fn extract_min_max(aor: *mut _IPAddressOrRange, min: *mut u8, max: *mut u8, leng
157155
unsafe {
158156
match (*aor).type_ {
159157
IPAddressOrRange_addressPrefix => {
160-
return addr_expand(min, (*aor).u.addressPrefix, length, 0x00)
158+
addr_expand(min, (*aor).u.addressPrefix, length, 0x00)
161159
&& addr_expand(max, (*aor).u.addressPrefix, length, 0xFF)
162160
}
163161
IPAddressOrRange_addressRange => {
164-
return addr_expand(min, (*(*aor).u.addressRange).min, length, 0x00)
162+
addr_expand(min, (*(*aor).u.addressRange).min, length, 0x00)
165163
&& addr_expand(max, (*(*aor).u.addressRange).max, length, 0xFF)
166164
}
167165
_ => false,

openssl/src/x509/sbgp.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ pub enum IPVersion {
122122
impl IPAddressFamily {
123123
pub fn fam(&self) -> Option<IPVersion> {
124124
let ptr = self.0;
125-
match X509v3_addr_get_afi(ptr) {
126-
IANA_AFI_IPV4 => Some(IPVersion::V4),
127-
IANA_AFI_IPV6 => Some(IPVersion::V6),
128-
_ => None,
125+
unsafe {
126+
match X509v3_addr_get_afi(ptr) {
127+
IANA_AFI_IPV4 => Some(IPVersion::V4),
128+
IANA_AFI_IPV6 => Some(IPVersion::V6),
129+
_ => None,
130+
}
129131
}
130132
}
131133

0 commit comments

Comments
 (0)