This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-12293-2fe35e952fe4243d69970f2f69037e2cf4452fb4
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git

commit d64e6f0424d4ee546fdcf7b1fac563da65576c5d
Author: Suraj <[email protected]>
AuthorDate: Thu Nov 19 20:20:18 2026 +0000

    fix(arrow-array):  validate FixedSizeBinaryBuilder value length without 
truncation (#12293)
    
    > [!IMPORTANT]
    >
    > Before opening this PR, [enable CI in your
    
fork](https://github.com/apache/arrow-rs/blob/main/CONTRIBUTING.md#pull-requests-from-forks).
    >
    > **Delete this notice after enabling CI.**
    
    # Which issue does this PR close?
    
     Closes #12285
    
    # Rationale for this change
    
    `FixedSizeBinaryBuilder::append_value` previously cast the input length
    to `i32`, allowing values whose length differed from `value_length` by a
    multiple of `2^32`.
    
    # What changes are included in this PR?
    
    Compare the input length as `usize` to avoid truncation.
---
 arrow-array/src/builder/fixed_size_binary_builder.rs            | 4 ++--
 arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arrow-array/src/builder/fixed_size_binary_builder.rs 
b/arrow-array/src/builder/fixed_size_binary_builder.rs
index 70f0dde26d..37240eadaf 100644
--- a/arrow-array/src/builder/fixed_size_binary_builder.rs
+++ b/arrow-array/src/builder/fixed_size_binary_builder.rs
@@ -65,7 +65,7 @@ impl FixedSizeBinaryBuilder {
     /// distinct value element.
     #[inline]
     pub fn append_value(&mut self, value: impl AsRef<[u8]>) -> Result<(), 
ArrowError> {
-        if self.value_length != value.as_ref().len() as i32 {
+        if value.as_ref().len() != self.value_length as usize {
             Err(ArrowError::InvalidArgumentError(
                 "Byte slice does not have the same length as 
FixedSizeBinaryBuilder value lengths"
                     .to_string(),
@@ -146,7 +146,7 @@ impl FixedSizeBinaryBuilder {
     }
     ///  Returns the total memory capacity in bytes currently
     pub fn capacity(&self) -> usize {
-        self.values_builder.capacity() + 
self.null_buffer_builder.allocated_size() + 4 // i32 
+        self.values_builder.capacity() + 
self.null_buffer_builder.allocated_size() + 4 // i32
     }
 }
 
diff --git a/arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs 
b/arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs
index 5ee8b05a0e..0c12c09a78 100644
--- a/arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs
+++ b/arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs
@@ -234,7 +234,7 @@ where
     ///
     /// Returns an error if the new index would overflow the key type.
     pub fn append(&mut self, value: impl AsRef<[u8]>) -> Result<K::Native, 
ArrowError> {
-        if self.byte_width != value.as_ref().len() as i32 {
+        if value.as_ref().len() != self.byte_width as usize {
             Err(ArrowError::InvalidArgumentError(format!(
                 "Invalid input length passed to FixedSizeBinaryBuilder. 
Expected {} got {}",
                 self.byte_width,
@@ -256,7 +256,7 @@ where
         value: impl AsRef<[u8]>,
         count: usize,
     ) -> Result<K::Native, ArrowError> {
-        if self.byte_width != value.as_ref().len() as i32 {
+        if value.as_ref().len() != self.byte_width as usize {
             Err(ArrowError::InvalidArgumentError(format!(
                 "Invalid input length passed to FixedSizeBinaryBuilder. 
Expected {} got {}",
                 self.byte_width,

Reply via email to