fix(tests): serve.mjs resolves --host before listening and refuses any wildcard result (every spelling: 0, 0::, ::ffff:0.0.0.0, scoped ::), listens on the resolved address and checks the bound one; report-compare opens once and checks size and type on the handle
This commit is contained in:
1 parent
80cc261c24
commit
9965d7f0a0
2 files changed
+48
-17
No files matched your search
@@ -118,7 +118,9 @@ impl Files for Disk {
|
||||
}
|
||||
|
||||
fn read(&self, path: &str) -> Result<Vec<u8>, FileFailure> {
|
||||
let meta = fs::metadata(path).map_err(|e| failure_of(&e))?;
|
||||
// One open, then the checks on that handle: the path is resolved once.
|
||||
let file = fs::File::open(path).map_err(|e| failure_of(&e))?;
|
||||
let meta = file.metadata().map_err(|e| failure_of(&e))?;
|
||||
if !meta.is_file() {
|
||||
return Err(FileFailure::NotRegular);
|
||||
}
|
||||
@@ -127,8 +129,8 @@ impl Files for Disk {
|
||||
}
|
||||
// Bounded read: a file that grew after the size check is still refused.
|
||||
let mut bytes = Vec::new();
|
||||
fs::File::open(path)
|
||||
.and_then(|f| f.take(MAX_PDF_BYTES as u64 + 1).read_to_end(&mut bytes))
|
||||
file.take(MAX_PDF_BYTES as u64 + 1)
|
||||
.read_to_end(&mut bytes)
|
||||
.map_err(|e| failure_of(&e))?;
|
||||
if bytes.len() > MAX_PDF_BYTES {
|
||||
return Err(FileFailure::TooLarge);
|
||||
|
||||
Reference in new issue
Block a user