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 8da6175c fix(array): bounds check FixedSizeBinary.Value (#923)
8da6175c is described below
commit 8da6175cc5af9a61729481ae22d2336992b417d3
Author: Minh Vu <[email protected]>
AuthorDate: Sun Jul 12 19:23:15 2026 +0200
fix(array): bounds check FixedSizeBinary.Value (#923)
Adds a logical index bounds check in FixedSizeBinary.Value before applying
the array offset, matching the Binary/String accessors and preventing
out-of-range reads on sliced arrays.
---
arrow/array/fixedsize_binary.go | 3 +++
arrow/array/fixedsize_binary_test.go | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/arrow/array/fixedsize_binary.go b/arrow/array/fixedsize_binary.go
index 31d507c5..8530ed6b 100644
--- a/arrow/array/fixedsize_binary.go
+++ b/arrow/array/fixedsize_binary.go
@@ -44,6 +44,9 @@ func NewFixedSizeBinaryData(data arrow.ArrayData)
*FixedSizeBinary {
// Value returns the fixed-size slice at index i. This value should not be
mutated.
func (a *FixedSizeBinary) Value(i int) []byte {
+ if i < 0 || i >= a.Len() {
+ panic("arrow/array: index out of range")
+ }
i += a.data.offset
var (
bw = int(a.bytewidth)
diff --git a/arrow/array/fixedsize_binary_test.go
b/arrow/array/fixedsize_binary_test.go
index d5499b80..8ebdacb1 100644
--- a/arrow/array/fixedsize_binary_test.go
+++ b/arrow/array/fixedsize_binary_test.go
@@ -113,6 +113,33 @@ func TestFixedSizeBinarySlice(t *testing.T) {
}
}
+func TestFixedSizeBinaryValueBounds(t *testing.T) {
+ mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
+ defer mem.AssertSize(t, 0)
+
+ dtype := &arrow.FixedSizeBinaryType{ByteWidth: 4}
+ b := array.NewFixedSizeBinaryBuilder(mem, dtype)
+ b.AppendValues([][]byte{
+ []byte("ABCD"),
+ []byte("1234"),
+ []byte("AZER"),
+ }, nil)
+ arr := b.NewFixedSizeBinaryArray()
+ defer arr.Release()
+ b.Release()
+
+ slice := array.NewSlice(arr, 1, 2).(*array.FixedSizeBinary)
+ defer slice.Release()
+
+ assert.Equal(t, []byte("1234"), slice.Value(0))
+ assert.PanicsWithValue(t, "arrow/array: index out of range", func() {
+ slice.Value(-1)
+ })
+ assert.PanicsWithValue(t, "arrow/array: index out of range", func() {
+ slice.Value(1)
+ })
+}
+
func TestFixedSizeBinary_MarshalUnmarshalJSON(t *testing.T) {
mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
defer mem.AssertSize(t, 0)