Commit 08c8cd59 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Remove using directives ("using namespace x") from sandbox/.

This also attempts to update the example code to match current style
and be as short as possible.

Bug: 82078
Change-Id: If068c395472f6a1243cb5e59dc2d7a8aa9e9cc3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816294
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699044}
parent 43c6ef3f
......@@ -27,34 +27,32 @@
// An idiomatic and demonstrative (albeit silly) example of this API
// would be:
//
// #include "sandbox/linux/bpf_dsl/bpf_dsl.h"
// #include "sandbox/linux/bpf_dsl/bpf_dsl.h"
//
// using namespace sandbox::bpf_dsl;
// namespace dsl = sandbox::bpf_dsl;
//
// class SillyPolicy : public Policy {
// public:
// SillyPolicy() {}
// ~SillyPolicy() override {}
// ResultExpr EvaluateSyscall(int sysno) const override {
// if (sysno == __NR_fcntl) {
// Arg<int> fd(0), cmd(1);
// Arg<unsigned long> flags(2);
// const uint64_t kGoodFlags = O_ACCMODE | O_NONBLOCK;
// return If(AllOf(fd == 0,
// cmd == F_SETFL,
// (flags & ~kGoodFlags) == 0),
// Allow())
// .ElseIf(AnyOf(cmd == F_DUPFD, cmd == F_DUPFD_CLOEXEC),
// Error(EMFILE))
// .Else(Trap(SetFlagHandler, NULL));
// } else {
// return Allow();
// }
// }
// class SillyPolicy : public dsl::Policy {
// public:
// SillyPolicy() = default;
// SillyPolicy(const SillyPolicy&) = delete;
// SillyPolicy& operator=(const SillyPolicy&) = delete;
// ~SillyPolicy() override = default;
//
// private:
// DISALLOW_COPY_AND_ASSIGN(SillyPolicy);
// };
// dsl::ResultExpr EvaluateSyscall(int sysno) const override {
// if (sysno != __NR_fcntl)
// return dsl::Allow();
// dsl::Arg<int> fd(0), cmd(1);
// dsl::Arg<unsigned long> flags(2);
// constexpr uint64_t kGoodFlags = O_ACCMODE | O_NONBLOCK;
// return dsl::If(dsl::AllOf(fd == 0,
// cmd == F_SETFL,
// (flags & ~kGoodFlags) == 0),
// dsl::Allow())
// .dsl::ElseIf(dsl::AnyOf(cmd == F_DUPFD, cmd == F_DUPFD_CLOEXEC),
// dsl::Error(EMFILE))
// .dsl::Else(dsl::Trap(SetFlagHandler, nullptr));
// }
// };
//
// More generally, the DSL currently supports the following grammar:
//
......
......@@ -9,20 +9,19 @@
#include "sandbox/win/src/ipc_args.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
using namespace sandbox;
uint32_t output_size = 0;
std::unique_ptr<CrossCallParamsEx> params(CrossCallParamsEx::CreateFromBuffer(
const_cast<uint8_t*>(data), size, &output_size));
std::unique_ptr<sandbox::CrossCallParamsEx> params(
sandbox::CrossCallParamsEx::CreateFromBuffer(const_cast<uint8_t*>(data),
size, &output_size));
if (!params.get())
return 0;
uint32_t tag = params->GetTag();
IPCParams ipc_params = {0};
sandbox::IPCParams ipc_params = {0};
ipc_params.ipc_tag = tag;
void* args[kMaxIpcParams];
GetArgs(params.get(), &ipc_params, args);
ReleaseArgs(&ipc_params, args);
void* args[sandbox::kMaxIpcParams];
sandbox::GetArgs(params.get(), &ipc_params, args);
sandbox::ReleaseArgs(&ipc_params, args);
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment