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-11883-e7c6d29df68a1c69af413af6848be7e787ea173f
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git

commit fb88f81d39601a5d0244d8ef034d7e2a10788c60
Author: Wleeaf <[email protected]>
AuthorDate: Sun Oct 25 22:07:22 2026 +0000

    fix(arrow-ipc): reject negative FixedSizeBinary byte width in IPC schema 
(#11883)
    
    # Which issue does this PR close?
    
    - Closes #11852.
    
    # Rationale for this change
    
    When converting an IPC schema, the `byteWidth` of a `FixedSizeBinary`
    field is used as is. A negative width produces a
    `DataType::FixedSizeBinary` that the rest of the code assumes is valid,
    which can lead to panics later on.
    
    # What changes are included in this PR?
    
    `get_data_type` returns a `ParseError` when the byte width is negative.
    A width of 0 is still accepted.
    
    # Are these changes tested?
    
    Yes. `try_fb_to_schema_negative_fixed_size_binary_width_is_err` builds a
    schema with a `FixedSizeBinary` field of width -1 and checks that the
    conversion returns an error. It fails without the fix and passes with
    it.
    
    # Are there any significant user-facing changes?
    
    No.
    
    AI usage: this change was prepared with Claude Code (an AI coding
    agent). The fix and test were generated by it and checked against a
    failing test for the issue.
    
    Co-authored-by: Wleeaf <[email protected]>
    Co-authored-by: RIchard Baah <[email protected]>
---
 arrow-ipc/src/convert.rs | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/arrow-ipc/src/convert.rs b/arrow-ipc/src/convert.rs
index 9affcd6b4a..936ad52b12 100644
--- a/arrow-ipc/src/convert.rs
+++ b/arrow-ipc/src/convert.rs
@@ -384,7 +384,13 @@ pub(crate) fn get_data_type(
             let fsb = field
                 .type_as_fixed_size_binary()
                 .ok_or_else(|| type_err("fixed size binary"))?;
-            DataType::FixedSizeBinary(fsb.byteWidth())
+            let byte_width = fsb.byteWidth();
+            if byte_width < 0 {
+                return Err(ArrowError::ParseError(format!(
+                    "FixedSizeBinary byte width must be non-negative, got 
{byte_width}"
+                )));
+            }
+            DataType::FixedSizeBinary(byte_width)
         }
         crate::Type::FloatingPoint => {
             let float = field
@@ -1152,6 +1158,22 @@ mod tests {
         assert_single_field_schema_is_err(fbb, field);
     }
 
+    #[test]
+    fn try_fb_to_schema_negative_fixed_size_binary_width_is_err() {
+        let mut fbb = FlatBufferBuilder::new();
+        let fsb =
+            crate::FixedSizeBinary::create(&mut fbb, 
&crate::FixedSizeBinaryArgs { byteWidth: -1 });
+        let field = crate::Field::create(
+            &mut fbb,
+            &crate::FieldArgs {
+                type_type: crate::Type::FixedSizeBinary,
+                type_: Some(fsb.as_union_value()),
+                ..Default::default()
+            },
+        );
+        assert_single_field_schema_is_err(fbb, field);
+    }
+
     #[test]
     fn try_fb_to_schema_type_none_is_err() {
         let mut fbb = FlatBufferBuilder::new();

Reply via email to