rust: bssl-tls: Check with the right buffer size limit for Rust FFI Signed-off-by: Xiangfei Ding <xfding@google.com> Change-Id: I4b7974f93d1a87a15a176f838488da786a6a6964 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/92507 Reviewed-by: Adam Langley <agl@google.com>
diff --git a/rust/bssl-tls/src/ffi.rs b/rust/bssl-tls/src/ffi.rs index 57be38d..ae06821 100644 --- a/rust/bssl-tls/src/ffi.rs +++ b/rust/bssl-tls/src/ffi.rs
@@ -47,7 +47,7 @@ if len == 0 || input.is_null() { return Some(&[]); } - if !input.is_aligned() || len.checked_mul(size_of::<T>())? >= isize::MAX as usize { + if !input.is_aligned() || len.checked_mul(size_of::<T>())? > isize::MAX as usize { return None; } unsafe { @@ -71,7 +71,7 @@ if capacity == 0 || out.is_null() || !out.is_aligned() { return Some(&mut []); } - if capacity.checked_mul(size_of::<T>())? >= isize::MAX as usize { + if capacity.checked_mul(size_of::<T>())? > isize::MAX as usize { return None; } unsafe {