MCPcopy Create free account
hub / github.com/PLSysSec/wave / expand_symlink

Function expand_symlink

src/path_resolution.rs:95–116  ·  view source on GitHub ↗
(
    out_path: &mut OwnedComponents,
    linkpath_components: OwnedComponents,
    num_symlinks: &mut isize,
    dirfd: HostFd,
)

Source from the content-addressed store, hash-verified

93#[ensures(!is_symlink(out_path))]
94#[ensures(forall(|i: usize| (i < out_path.len()) ==> !is_symlink(out_path.prefix(i)) ))]
95fn expand_symlink(
96 out_path: &mut OwnedComponents,
97 linkpath_components: OwnedComponents,
98 num_symlinks: &mut isize,
99 dirfd: HostFd,
100) {
101 let mut idx = 0;
102 while idx < linkpath_components.len() {
103 body_invariant!(!is_symlink(out_path));
104 // out_path should never contain symlinks
105 body_invariant!(forall(|i: usize| i < out_path.len() ==> !is_symlink(out_path.prefix(i))));
106 if *num_symlinks >= MAXSYMLINKS {
107 return;
108 }
109 let c = linkpath_components.lookup(idx);
110 let maybe_linkpath = maybe_expand_component(dirfd, out_path, c, num_symlinks);
111 if let Some(linkpath) = maybe_linkpath {
112 expand_symlink(out_path, linkpath, num_symlinks, dirfd);
113 }
114 idx += 1;
115 }
116}

Callers 1

expand_pathFunction · 0.85

Calls 3

maybe_expand_componentFunction · 0.85
lenMethod · 0.45
lookupMethod · 0.45

Tested by

no test coverage detected