mirror of
https://github.com/BLAKE3-team/BLAKE3
synced 2024-05-08 10:46:20 +02:00
RUSTSEC-2020-0077
Migrate from the abandoned memmap library to the now maintained fork of memmap2
This commit is contained in:
parent
9cd41c0cfd
commit
989c30e249
|
@ -46,7 +46,7 @@ dependencies = [
|
|||
"clap",
|
||||
"duct",
|
||||
"hex",
|
||||
"memmap",
|
||||
"memmap2",
|
||||
"rayon",
|
||||
"tempfile",
|
||||
"wild",
|
||||
|
@ -280,13 +280,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
|
||||
[[package]]
|
||||
name = "memmap"
|
||||
version = "0.7.0"
|
||||
name = "memmap2"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
|
||||
checksum = "057a3db23999c867821a7a59feb06a578fcb03685e983dff90daf9e7d24ac08f"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ impl Args {
|
|||
}
|
||||
|
||||
enum Input {
|
||||
Mmap(io::Cursor<memmap::Mmap>),
|
||||
Mmap(io::Cursor<memmap2::Mmap>),
|
||||
File(File),
|
||||
Stdin,
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue