@@ -75,18 +75,16 @@ extern "C" {
75
75
pub fn IPAddressOrRange_free ( asi : * mut _IPAddressOrRange ) ;
76
76
}
77
77
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 ( ) {
81
84
0
82
85
} 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
90
88
}
91
89
}
92
90
}
@@ -142,7 +140,7 @@ fn addr_expand(addr: *mut u8, bs: *const ASN1_BIT_STRING, length: isize, fill: u
142
140
}
143
141
144
142
// fill up bytes
145
- for i in ( str_len as isize ) ..( length as isize ) {
143
+ for i in ( str_len as isize ) ..length {
146
144
* addr. offset ( i) = fill;
147
145
}
148
146
}
@@ -157,11 +155,11 @@ fn extract_min_max(aor: *mut _IPAddressOrRange, min: *mut u8, max: *mut u8, leng
157
155
unsafe {
158
156
match ( * aor) . type_ {
159
157
IPAddressOrRange_addressPrefix => {
160
- return addr_expand ( min, ( * aor) . u . addressPrefix , length, 0x00 )
158
+ addr_expand ( min, ( * aor) . u . addressPrefix , length, 0x00 )
161
159
&& addr_expand ( max, ( * aor) . u . addressPrefix , length, 0xFF )
162
160
}
163
161
IPAddressOrRange_addressRange => {
164
- return addr_expand ( min, ( * ( * aor) . u . addressRange ) . min , length, 0x00 )
162
+ addr_expand ( min, ( * ( * aor) . u . addressRange ) . min , length, 0x00 )
165
163
&& addr_expand ( max, ( * ( * aor) . u . addressRange ) . max , length, 0xFF )
166
164
}
167
165
_ => false ,
0 commit comments