metsw24-max commented on code in PR #50060:
URL: https://github.com/apache/arrow/pull/50060#discussion_r3496812801


##########
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:
   Good point, the right-hand side could overflow the same way. Both ends now 
go through AddWithOverflow and compare the validated index_end against 
range_end.



##########
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:
   Done, moved the offset bound check to the front so it short-circuits before 
the additions.



-- 
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