Skip to content

Commit da7f26d

Browse files
committed
fix max_values()
1 parent 864662b commit da7f26d

File tree

15 files changed

+37
-37
lines changed

15 files changed

+37
-37
lines changed

openssl/src/aes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl AesKey {
9595
#[corresponds(AES_set_encrypt_key)]
9696
pub fn new_encrypt(key: &[u8]) -> Result<AesKey, KeyError> {
9797
unsafe {
98-
assert!(key.len() <= c_int::max_value() as usize / 8);
98+
assert!(key.len() <= c_int::MAX as usize / 8);
9999

100100
let mut aes_key = MaybeUninit::uninit();
101101
let r = ffi::AES_set_encrypt_key(
@@ -119,7 +119,7 @@ impl AesKey {
119119
#[corresponds(AES_set_decrypt_key)]
120120
pub fn new_decrypt(key: &[u8]) -> Result<AesKey, KeyError> {
121121
unsafe {
122-
assert!(key.len() <= c_int::max_value() as usize / 8);
122+
assert!(key.len() <= c_int::MAX as usize / 8);
123123

124124
let mut aes_key = MaybeUninit::uninit();
125125
let r = ffi::AES_set_decrypt_key(

openssl/src/base64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use openssl_macros::corresponds;
1111
/// Panics if the input length or computed output length overflow a signed C integer.
1212
#[corresponds(EVP_EncodeBlock)]
1313
pub fn encode_block(src: &[u8]) -> String {
14-
assert!(src.len() <= c_int::max_value() as usize);
14+
assert!(src.len() <= c_int::MAX as usize);
1515
let src_len = src.len() as LenType;
1616

1717
let len = encoded_len(src_len).unwrap();
@@ -42,7 +42,7 @@ pub fn decode_block(src: &str) -> Result<Vec<u8>, ErrorStack> {
4242
return Ok(vec![]);
4343
}
4444

45-
assert!(src.len() <= c_int::max_value() as usize);
45+
assert!(src.len() <= c_int::MAX as usize);
4646
let src_len = src.len() as LenType;
4747

4848
let len = decoded_len(src_len).unwrap();

openssl/src/bio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<'a> MemBioSlice<'a> {
2121
pub fn new(buf: &'a [u8]) -> Result<MemBioSlice<'a>, ErrorStack> {
2222
ffi::init();
2323

24-
assert!(buf.len() <= c_int::max_value() as usize);
24+
assert!(buf.len() <= c_int::MAX as usize);
2525
let bio = unsafe {
2626
cvt_p(BIO_new_mem_buf(
2727
buf.as_ptr() as *const _,

openssl/src/bn.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl BigNumRef {
187187
pub fn div_word(&mut self, w: u32) -> Result<u64, ErrorStack> {
188188
unsafe {
189189
let r = ffi::BN_div_word(self.as_ptr(), w.into());
190-
if r == ffi::BN_ULONG::max_value() {
190+
if r == ffi::BN_ULONG::MAX {
191191
Err(ErrorStack::get())
192192
} else {
193193
Ok(r.into())
@@ -201,7 +201,7 @@ impl BigNumRef {
201201
pub fn mod_word(&self, w: u32) -> Result<u64, ErrorStack> {
202202
unsafe {
203203
let r = ffi::BN_mod_word(self.as_ptr(), w.into());
204-
if r == ffi::BN_ULONG::max_value() {
204+
if r == ffi::BN_ULONG::MAX {
205205
Err(ErrorStack::get())
206206
} else {
207207
Ok(r.into())
@@ -1108,7 +1108,7 @@ impl BigNum {
11081108
pub fn from_slice(n: &[u8]) -> Result<BigNum, ErrorStack> {
11091109
unsafe {
11101110
ffi::init();
1111-
assert!(n.len() <= LenType::max_value() as usize);
1111+
assert!(n.len() <= LenType::MAX as usize);
11121112

11131113
cvt_p(ffi::BN_bin2bn(
11141114
n.as_ptr(),
@@ -1136,7 +1136,7 @@ impl BigNum {
11361136
#[corresponds(BN_bin2bn)]
11371137
pub fn copy_from_slice(&mut self, n: &[u8]) -> Result<(), ErrorStack> {
11381138
unsafe {
1139-
assert!(n.len() <= LenType::max_value() as usize);
1139+
assert!(n.len() <= LenType::MAX as usize);
11401140

11411141
cvt_p(ffi::BN_bin2bn(n.as_ptr(), n.len() as LenType, self.0))?;
11421142
Ok(())

openssl/src/ecdsa.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl EcdsaSig {
3232
T: HasPrivate,
3333
{
3434
unsafe {
35-
assert!(data.len() <= c_int::max_value() as usize);
35+
assert!(data.len() <= c_int::MAX as usize);
3636
let sig = cvt_p(ffi::ECDSA_do_sign(
3737
data.as_ptr(),
3838
data.len() as LenType,
@@ -77,7 +77,7 @@ impl EcdsaSigRef {
7777
T: HasPublic,
7878
{
7979
unsafe {
80-
assert!(data.len() <= c_int::max_value() as usize);
80+
assert!(data.len() <= c_int::MAX as usize);
8181
cvt_n(ffi::ECDSA_do_verify(
8282
data.as_ptr(),
8383
data.len() as LenType,

openssl/src/envelope.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Seal {
7575
///
7676
/// Panics if `output.len() < input.len() + block_size` where `block_size` is
7777
/// the block size of the cipher (see `Cipher::block_size`), or if
78-
/// `output.len() > c_int::max_value()`.
78+
/// `output.len() > c_int::MAX`.
7979
pub fn update(&mut self, input: &[u8], output: &mut [u8]) -> Result<usize, ErrorStack> {
8080
self.ctx.cipher_update(input, Some(output))
8181
}
@@ -130,7 +130,7 @@ impl Open {
130130
///
131131
/// Panics if `output.len() < input.len() + block_size` where
132132
/// `block_size` is the block size of the cipher (see `Cipher::block_size`),
133-
/// or if `output.len() > c_int::max_value()`.
133+
/// or if `output.len() > c_int::MAX`.
134134
pub fn update(&mut self, input: &[u8], output: &mut [u8]) -> Result<usize, ErrorStack> {
135135
self.ctx.cipher_update(input, Some(output))
136136
}

openssl/src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ macro_rules! private_key_to_pem {
5959
) -> Result<Vec<u8>, crate::error::ErrorStack> {
6060
unsafe {
6161
let bio = crate::bio::MemBio::new()?;
62-
assert!(passphrase.len() <= ::libc::c_int::max_value() as usize);
62+
assert!(passphrase.len() <= ::libc::c_int::MAX as usize);
6363
cvt($f(bio.as_ptr(),
6464
self.as_ptr(),
6565
cipher.as_ptr(),
@@ -109,7 +109,7 @@ macro_rules! from_der {
109109
use std::convert::TryInto;
110110
unsafe {
111111
ffi::init();
112-
let len = ::std::cmp::min(der.len(), ::libc::c_long::max_value() as usize) as ::libc::c_long;
112+
let len = ::std::cmp::min(der.len(), ::libc::c_long::MAX as usize) as ::libc::c_long;
113113
crate::cvt_p($f(::std::ptr::null_mut(), &mut der.as_ptr(), len.try_into().unwrap()))
114114
.map(|p| ::foreign_types::ForeignType::from_ptr(p))
115115
}

openssl/src/pkcs5.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn bytes_to_key(
3838
count: i32,
3939
) -> Result<KeyIvPair, ErrorStack> {
4040
unsafe {
41-
assert!(data.len() <= c_int::max_value() as usize);
41+
assert!(data.len() <= c_int::MAX as usize);
4242
let salt_ptr = match salt {
4343
Some(salt) => {
4444
assert_eq!(salt.len(), ffi::PKCS5_SALT_LEN as usize);

openssl/src/pkey.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ impl PKey<Private> {
482482
#[cfg(not(boringssl))]
483483
pub fn hmac(key: &[u8]) -> Result<PKey<Private>, ErrorStack> {
484484
unsafe {
485-
assert!(key.len() <= c_int::max_value() as usize);
485+
assert!(key.len() <= c_int::MAX as usize);
486486
let key = cvt_p(ffi::EVP_PKEY_new_mac_key(
487487
ffi::EVP_PKEY_HMAC,
488488
ptr::null_mut(),
@@ -676,7 +676,7 @@ impl PKey<Private> {
676676
pub fn private_key_from_pkcs8(der: &[u8]) -> Result<PKey<Private>, ErrorStack> {
677677
unsafe {
678678
ffi::init();
679-
let len = der.len().min(c_long::max_value() as usize) as c_long;
679+
let len = der.len().min(c_long::MAX as usize) as c_long;
680680
let p8inf = cvt_p(ffi::d2i_PKCS8_PRIV_KEY_INFO(
681681
ptr::null_mut(),
682682
&mut der.as_ptr(),

openssl/src/rand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use openssl_macros::corresponds;
3232
pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> {
3333
unsafe {
3434
ffi::init();
35-
assert!(buf.len() <= c_int::max_value() as usize);
35+
assert!(buf.len() <= c_int::MAX as usize);
3636
cvt(ffi::RAND_bytes(buf.as_mut_ptr(), buf.len() as LenType)).map(|_| ())
3737
}
3838
}
@@ -57,7 +57,7 @@ pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> {
5757
pub fn rand_priv_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> {
5858
unsafe {
5959
ffi::init();
60-
assert!(buf.len() <= c_int::max_value() as usize);
60+
assert!(buf.len() <= c_int::MAX as usize);
6161
cvt(ffi::RAND_priv_bytes(buf.as_mut_ptr(), buf.len() as LenType)).map(|_| ())
6262
}
6363
}

0 commit comments

Comments
 (0)