mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-14 22:42:46 +00:00
Merge pull request #1362 from storytold/sec/docpath-long-path
craft-docpath: prove a multi-megabyte UNC path parses iteratively
This commit is contained in:
1 file changed
+29
@@ -0,0 +1,29 @@
|
||||
//! Paths long enough that a per-level recursive descent would exhaust the stack. Parsing is
|
||||
//! iterative — `resolve` and `classify` reach `parse_share` at a fixed depth — so these come
|
||||
//! back; a refusal is fine, a crash is not.
|
||||
|
||||
use craft_docpath::{classify, resolve};
|
||||
|
||||
/// Half a megabyte of components under a UNC share: one component per level for a parser that
|
||||
/// recursed on each separator.
|
||||
#[test]
|
||||
fn a_half_megabyte_unc_path_comes_back() {
|
||||
let mut path = String::from(r"\\?\UNC\host\share");
|
||||
for _ in 0..(1 << 18) {
|
||||
path.push_str(r"\d");
|
||||
}
|
||||
let _ = resolve(&path, None);
|
||||
let _ = classify(&path);
|
||||
}
|
||||
|
||||
/// Sixteen thousand nested verbatim prefixes: each level was a candidate recursive call when the
|
||||
/// UNC prefixes were first reviewed.
|
||||
#[test]
|
||||
fn nested_verbatim_prefixes_come_back() {
|
||||
let mut path = String::new();
|
||||
for _ in 0..(1 << 14) {
|
||||
path.push_str(r"\\?\UNC\");
|
||||
}
|
||||
let _ = resolve(&path, None);
|
||||
let _ = classify(&path);
|
||||
}
|
||||
Reference in new issue
Block a user