Skip to content

Commit

Permalink
Merge pull request #12 from sunrise-choir/fix_unsoundness
Browse files Browse the repository at this point in the history
Ensure buffer is zeroed for reading
  • Loading branch information
pietgeursen authored Jan 13, 2022
2 parents 65084dd + 1b643df commit 14b7440
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/go_offset_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ where
{
// Entry is [payload size: u64, payload ]

let mut buf = Vec::with_capacity(frame.data_size);
unsafe { buf.set_len(frame.data_size) };
let mut buf = vec![0; frame.data_size];

let n = read_at(&mut buf, frame.data_start())?;
if n < frame.data_size {
Expand Down
5 changes: 2 additions & 3 deletions src/offset_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,7 @@ where
let tail_size = size_of_frame_tail::<ByteType>();
let to_read = frame.data_size + tail_size;

let mut buf = Vec::with_capacity(to_read);
unsafe { buf.set_len(to_read) };
let mut buf = vec![0; to_read];

let n = read_at(&mut buf, frame.data_start())?;
if n < to_read {
Expand All @@ -353,7 +352,7 @@ where
offset: frame.offset,
data: buf,
},
next: next,
next,
})
}

Expand Down

0 comments on commit 14b7440

Please # to comment.