wgtmac commented on code in PR #50060:
URL: https://github.com/apache/arrow/pull/50060#discussion_r3490425086


##########
cpp/src/parquet/page_index.cc:
##########
@@ -335,9 +335,11 @@ class RowGroupPageIndexReaderImpl : public 
RowGroupPageIndexReader {
     }
 
     /// Page index location must be within the range of the read range.
-    if (index_location.offset < index_read_range->offset ||
-        index_location.offset + index_location.length >
-            index_read_range->offset + index_read_range->length) {
+    int64_t index_end = 0;
+    if (::arrow::internal::AddWithOverflow(index_location.offset, 
index_location.length,
+                                           &index_end) ||
+        index_location.offset < index_read_range->offset ||

Review Comment:
   Should we check `index_location.offset < index_read_range->offset` first to 
fail fast without calling `AddWithOverflow`?



##########
cpp/src/parquet/page_index.cc:
##########
@@ -335,9 +335,11 @@ class RowGroupPageIndexReaderImpl : public 
RowGroupPageIndexReader {
     }
 
     /// Page index location must be within the range of the read range.
-    if (index_location.offset < index_read_range->offset ||
-        index_location.offset + index_location.length >
-            index_read_range->offset + index_read_range->length) {
+    int64_t index_end = 0;
+    if (::arrow::internal::AddWithOverflow(index_location.offset, 
index_location.length,
+                                           &index_end) ||
+        index_location.offset < index_read_range->offset ||
+        index_end > index_read_range->offset + index_read_range->length) {

Review Comment:
   Why not validating `index_read_range->offset + index_read_range->length` as 
well?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to