Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/linux/apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1441,8 +1441,8 @@ Status Plan::apply_range(Phase first, Phase last, ApplyFds& fds) const {
if (nf > 0) {
buf[nf] = '\0';
std::uint64_t ino = 0;
for (const char* p = buf; *p; ++p)
if (*p >= '0' && *p <= '9') ino = ino * 10 + std::uint64_t(*p - '0');
for (const char* d = buf; *d; ++d)
if (*d >= '0' && *d <= '9') ino = ino * 10 + std::uint64_t(*d - '0');
fds.proxy_netns_ino = ino;
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/windows/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,30 +203,30 @@ Result<Compiled> compile(const Policy<Sealed>& policy, const HostCapabilities& h
// past the policy-vocabulary roots: native forms only, with the
// drive prefix already stripped above. anything else starting with
// "/" failed the root table and never reaches here.
std::string out;
out.reserve(s.size());
std::string native;
native.reserve(s.size());
bool prev_sep = false;
for (const char c : s) {
if (c == '/' || c == '\\') {
if (!prev_sep && !out.empty()) out.push_back('\\');
if (!prev_sep && !native.empty()) native.push_back('\\');
prev_sep = true;
} else {
out.push_back(c);
native.push_back(c);
prev_sep = false;
}
}
while (!out.empty() && out.back() == '\\') out.pop_back();
if (out.empty())
while (!native.empty() && native.back() == '\\') native.pop_back();
if (native.empty())
return std::unexpected(Error{Errc::invalid_policy, "path normalizes to nothing"});

const bool drive = out.size() >= 2 && out[1] == ':' &&
((out[0] >= 'A' && out[0] <= 'Z') ||
(out[0] >= 'a' && out[0] <= 'z'));
const bool unc = out.size() >= 2 && out[0] == '\\' && out[1] == '\\';
const bool drive = native.size() >= 2 && native[1] == ':' &&
((native[0] >= 'A' && native[0] <= 'Z') ||
(native[0] >= 'a' && native[0] <= 'z'));
const bool unc = native.size() >= 2 && native[0] == '\\' && native[1] == '\\';
if (!drive && !unc)
return std::unexpected(Error{Errc::invalid_policy,
"path has no drive prefix (need C:\\... or \\\\server\\\\share)"});
return out;
return native;
};

for (const auto& g : effective.grants()) {
Expand Down
Loading