Skip to content

Commit

Permalink
RUSTSEC-2020-0077
Browse files Browse the repository at this point in the history
Migrate from the abandoned memmap library to the now maintained fork
of memmap2
  • Loading branch information
strangelittlemonkey committed Mar 26, 2022
1 parent 9cd41c0 commit 989c30e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions b3sum/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion b3sum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ anyhow = "1.0.25"
blake3 = { version = "1", path = "..", features = ["rayon"] }
clap = "3.0.5"
hex = "0.4.0"
memmap = "0.7.0"
memmap2 = "0.5.3"
rayon = "1.2.1"
wild = "2.0.3"

Expand Down
8 changes: 4 additions & 4 deletions b3sum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl Args {
}

enum Input {
Mmap(io::Cursor<memmap::Mmap>),
Mmap(io::Cursor<memmap2::Mmap>),
File(File),
Stdin,
}
Expand Down Expand Up @@ -276,7 +276,7 @@ fn copy_wide(mut reader: impl Read, hasher: &mut blake3::Hasher) -> io::Result<u
// Mmap a file, if it looks like a good idea. Return None in cases where we
// know mmap will fail, or if the file is short enough that mmapping isn't
// worth it. However, if we do try to mmap and it fails, return the error.
fn maybe_memmap_file(file: &File) -> Result<Option<memmap::Mmap>> {
fn maybe_memmap_file(file: &File) -> Result<Option<memmap2::Mmap>> {
let metadata = file.metadata()?;
let file_size = metadata.len();
Ok(if !metadata.is_file() {
Expand All @@ -297,9 +297,9 @@ fn maybe_memmap_file(file: &File) -> Result<Option<memmap::Mmap>> {
// Explicitly set the length of the memory map, so that filesystem
// changes can't race to violate the invariants we just checked.
let map = unsafe {
memmap::MmapOptions::new()
memmap2::MmapOptions::new()
.len(file_size as usize)
.map(&file)?
.map(file)?
};
Some(map)
})
Expand Down

0 comments on commit 989c30e

Please sign in to comment.