Skip to content

Commit

Permalink
fix verifier in hello-world example
Browse files Browse the repository at this point in the history
Issue #44
  • Loading branch information
deian authored and shravanrn committed Apr 4, 2022
1 parent b821a5a commit 9094b01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion examples/hello-world-cmake/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define RLBOX_USE_STATIC_CALLS() rlbox_noop_sandbox_lookup_symbol

#include <stdio.h>
#include <cassert>
#include <rlbox/rlbox.hpp>
#include <rlbox/rlbox_noop_sandbox.hpp>
#include "mylib.h"
Expand All @@ -12,7 +13,8 @@ void hello_cb(rlbox_sandbox<rlbox_noop_sandbox>& _,
tainted<const char*, rlbox_noop_sandbox> str) {
auto checked_string =
str.copy_and_verify_string([](std::unique_ptr<char[]> val) {
return std::strlen(val.get()) < 1024 ? std::move(val) : nullptr;
assert(val != nullptr && std::strlen(val.get()) < 1024);
return std::move(val);
});
printf("hello_cb: %s\n", checked_string.get());
}
Expand Down
4 changes: 3 additions & 1 deletion examples/hello-world-noop/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define RLBOX_USE_STATIC_CALLS() rlbox_noop_sandbox_lookup_symbol

#include <stdio.h>
#include <cassert>
#include "mylib.h"
#include "../../code/include/rlbox.hpp"
#include "../../code/include/rlbox_noop_sandbox.hpp"
Expand All @@ -12,7 +13,8 @@ void hello_cb(rlbox_sandbox<rlbox_noop_sandbox>& _,
tainted<const char*, rlbox_noop_sandbox> str) {
auto checked_string =
str.copy_and_verify_string([](std::unique_ptr<char[]> val) {
return std::strlen(val.get()) < 1024 ? std::move(val) : nullptr;
assert(val != nullptr && std::strlen(val.get()) < 1024);
return std::move(val);
});
printf("hello_cb: %s\n", checked_string.get());
}
Expand Down

0 comments on commit 9094b01

Please sign in to comment.