etseidl commented on code in PR #8889:
URL: https://github.com/apache/arrow-rs/pull/8889#discussion_r2546477854


##########
parquet/src/column/reader.rs:
##########
@@ -437,6 +437,9 @@ where
                             let mut offset = 0;
 
                             if max_rep_level > 0 {
+                                if offset > buf.len() {

Review Comment:
   This one should never evaluate `true`?



##########
parquet/src/column/reader.rs:
##########
@@ -466,9 +472,12 @@ where
                                 self.def_level_decoder
                                     .as_mut()
                                     .unwrap()
-                                    .set_data(def_level_encoding, level_data)?;
+                                    .set_data(def_level_encoding, level_data);
                             }
 
+                            if offset > buf.len() {

Review Comment:
   If the checks above are moved to after `offset` is incremented, then I think 
this check can be eliminated as it will either always be true (`offset` is 
still 0), or the error condition was already caught.



##########
parquet/src/column/reader.rs:
##########
@@ -509,27 +518,33 @@ where
                                 self.has_record_delimiter =
                                     self.page_reader.at_record_boundary()?;
 
+                                if rep_levels_byte_len as usize > buf.len() {
+                                    return Err(general_err!("not enough data 
to read levels"));
+                                }
                                 
self.rep_level_decoder.as_mut().unwrap().set_data(
                                     Encoding::RLE,
                                     buf.slice(..rep_levels_byte_len as usize),
-                                )?;
+                                );
                             }
 
+                            let def_levels_end = rep_levels_byte_len + 
def_levels_byte_len;

Review Comment:
   Why not move this check higher up and check all levels in one shot?



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