You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/14 20:06:50 UTC

[GitHub] [arrow] zeroshade commented on a diff in pull request #13381: ARROW-16831: [Go] panic in ipc.Reader when string array offsets are invalid

zeroshade commented on code in PR #13381:
URL: https://github.com/apache/arrow/pull/13381#discussion_r897274054


##########
go/arrow/array/string.go:
##########
@@ -113,6 +113,12 @@ func (a *String) setData(data *Data) {
 	if offsets := data.buffers[1]; offsets != nil {
 		a.offsets = arrow.Int32Traits.CastFromBytes(offsets.Bytes())
 	}
+
+	expNumOffsets := a.array.data.offset + a.array.data.length + 1
+	if a.array.data.length > 0 &&
+		(len(a.offsets) < expNumOffsets || int(a.offsets[expNumOffsets-2]) > len(a.values)) {
+		panic("arrow/array: string offsets out of bounds of data buffer")
+	}

Review Comment:
   is the `a.array.data.length > 0` actually needed? Also, shouldn't this be `len(a.offsets) >= expNumOffsets` ?
   
   `a.offsets[expNumOffsets-2]` would be incorrect, why the -2? `a.offsets[expNumOffset]` should be the final byte.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org