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

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-go.git


The following commit(s) were added to refs/heads/main by this push:
     new 182bb17e fix(array): reject unsupported type IDs (#925)
182bb17e is described below

commit 182bb17ed4ef0c4d8ca44be95be67366bd27e1be
Author: Minh Vu <[email protected]>
AuthorDate: Sun Jul 12 19:37:07 2026 +0200

    fix(array): reject unsupported type IDs (#925)
    
    Replaces the six-bit type-ID mask in MakeFromData with an explicit bounds 
and nil-constructor check so unsupported type IDs (>= 64) can no longer alias 
valid array constructors.
---
 arrow/array/array.go      | 6 +++++-
 arrow/array/array_test.go | 5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arrow/array/array.go b/arrow/array/array.go
index 947b44f2..c47735fc 100644
--- a/arrow/array/array.go
+++ b/arrow/array/array.go
@@ -117,7 +117,11 @@ func invalidDataType(data arrow.ArrayData) arrow.Array {
 
 // MakeFromData constructs a strongly-typed array instance from generic Data.
 func MakeFromData(data arrow.ArrayData) arrow.Array {
-       return makeArrayFn[byte(data.DataType().ID()&0x3f)](data)
+       id := data.DataType().ID()
+       if id < 0 || int(id) >= len(makeArrayFn) || makeArrayFn[id] == nil {
+               return invalidDataType(data)
+       }
+       return makeArrayFn[id](data)
 }
 
 // NewSlice constructs a zero-copy slice of the array with the indicated
diff --git a/arrow/array/array_test.go b/arrow/array/array_test.go
index 9509e314..63e52a30 100644
--- a/arrow/array/array_test.go
+++ b/arrow/array/array_test.go
@@ -40,6 +40,7 @@ func (testDataType) Layout() arrow.DataTypeLayout { return 
arrow.DataTypeLayout{
 func (testDataType) String() string               { return "" }
 
 func TestMakeFromData(t *testing.T) {
+       const veryLargeTypeID arrow.Type = 1 << 30
        tests := []struct {
                name     string
                d        arrow.DataType
@@ -134,6 +135,10 @@ func TestMakeFromData(t *testing.T) {
                // invalid types
                {name: "invalid(-1)", d: &testDataType{arrow.Type(-1)}, 
expPanic: true, expError: "invalid data type: Type(-1)"},
                {name: "invalid(63)", d: &testDataType{arrow.Type(63)}, 
expPanic: true, expError: "invalid data type: Type(63)"},
+               {name: "invalid(64)", d: &testDataType{arrow.Type(64)}, 
expPanic: true, expError: "invalid data type: Type(64)"},
+               {name: "invalid(65)", d: &testDataType{arrow.Type(65)}, 
expPanic: true, expError: "invalid data type: Type(65)"},
+               {name: "invalid(127)", d: &testDataType{arrow.Type(127)}, 
expPanic: true, expError: "invalid data type: Type(127)"},
+               {name: "invalid(very large)", d: 
&testDataType{veryLargeTypeID}, expPanic: true, expError: "invalid data type: 
Type(1073741824)"},
        }
        for _, test := range tests {
                t.Run(test.name, func(t *testing.T) {

Reply via email to