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 2021/06/06 14:06:25 UTC

[GitHub] [arrow-rs] jhorstmann commented on a change in pull request #416: Fix out of bounds read in bit chunk iterator

jhorstmann commented on a change in pull request #416:
URL: https://github.com/apache/arrow-rs/pull/416#discussion_r646137904



##########
File path: arrow/src/util/bit_chunk_iterator.rs
##########
@@ -137,14 +137,16 @@ impl Iterator for BitChunkIterator<'_> {
         // so when reading as u64 on a big-endian machine, the bytes need to be swapped
         let current = unsafe { std::ptr::read_unaligned(raw_data.add(index)).to_le() };
 
-        let combined = if self.bit_offset == 0 {
+        let bit_offset = self.bit_offset;
+
+        let combined = if bit_offset == 0 {
             current
         } else {
-            let next =
-                unsafe { std::ptr::read_unaligned(raw_data.add(index + 1)).to_le() };
+            let next = unsafe {
+                std::ptr::read_unaligned(raw_data.add(index + 1) as *const u8) as u64

Review comment:
       The fix here is casting the pointer back to *u8 and reading only a single byte.
   
   The other changes are a bit of a cleanup, the masking of `next` below should not be needed since it masked of exactly the bits that would be shifted out.




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

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