You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2026/05/05 17:24:27 UTC

[PR] [57_maintenance] Prevent Rows row index overflow (#9817) [arrow-rs]

alamb opened a new pull request, #9922:
URL: https://github.com/apache/arrow-rs/pull/9922

   - Part of https://github.com/apache/arrow-rs/issues/9858
   - Fixes https://github.com/apache/arrow-rs/issues/9901 in 57.x releases
   
   This PR:
   - Backports https://github.com/apache/arrow-rs/pull/9817 from @alamb to the `57_maintenance` line
   
   Note: `Rows::row_len` is not present on the `57_maintenance` line, so this backport applies the checked row index validation to `Rows::row`.
   


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


Re: [PR] [57_maintenance] Prevent Rows row index overflow (#9817) [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #9922:
URL: https://github.com/apache/arrow-rs/pull/9922


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


Re: [PR] [57_maintenance] Prevent Rows row index overflow (#9817) [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9922:
URL: https://github.com/apache/arrow-rs/pull/9922#discussion_r3190725246


##########
arrow-row/src/lib.rs:
##########
@@ -1132,14 +1132,20 @@ impl Rows {
 
     /// Returns the row at index `row`
     pub fn row(&self, row: usize) -> Row<'_> {
-        assert!(row + 1 < self.offsets.len());
+        self.checked_row_end(row);
         unsafe { self.row_unchecked(row) }
     }
 
+    fn checked_row_end(&self, row: usize) -> usize {
+        row.checked_add(1)
+            .filter(|end| *end < self.offsets.len())
+            .expect("row index out of bounds")
+    }
+
     /// Returns the row at `index` without bounds checking

Review Comment:
   As the description points out the reason https://github.com/apache/arrow-rs/pull/9817 has more changes than this PR is:
   
   > Note: Rows::row_len and Rows::lengths are not present on the 57_maintenance line, so this backport applies the checked row index validation to Rows::row and includes the row_unchecked safety documentation update from the original PR.
   
   This was introduced in 
   -  https://github.com/apache/arrow-rs/pull/9079 / https://github.com/apache/arrow-rs/commit/13d497af2be5d91c1c57775b8a57487ca05babe3
   
   which was first released in 58.2.0



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


Re: [PR] [57_maintenance] Prevent Rows row index overflow (#9817) [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9922:
URL: https://github.com/apache/arrow-rs/pull/9922#discussion_r3190725246


##########
arrow-row/src/lib.rs:
##########
@@ -1132,14 +1132,20 @@ impl Rows {
 
     /// Returns the row at index `row`
     pub fn row(&self, row: usize) -> Row<'_> {
-        assert!(row + 1 < self.offsets.len());
+        self.checked_row_end(row);
         unsafe { self.row_unchecked(row) }
     }
 
+    fn checked_row_end(&self, row: usize) -> usize {
+        row.checked_add(1)
+            .filter(|end| *end < self.offsets.len())
+            .expect("row index out of bounds")
+    }
+
     /// Returns the row at `index` without bounds checking

Review Comment:
   As the description points out: 
   
   > Note: Rows::row_len and Rows::lengths are not present on the 57_maintenance line, so this backport applies the checked row index validation to Rows::row and includes the row_unchecked safety documentation update from the original PR.
   
   This was introduced in 
   -  https://github.com/apache/arrow-rs/pull/9079 / https://github.com/apache/arrow-rs/commit/13d497af2be5d91c1c57775b8a57487ca05babe3
   
   which was first released in 58.2.0



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