Skip to content

Commit 9094b01

Browse files
deianshravanrn
authored andcommitted
fix verifier in hello-world example
Issue #44
1 parent b821a5a commit 9094b01

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

examples/hello-world-cmake/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define RLBOX_USE_STATIC_CALLS() rlbox_noop_sandbox_lookup_symbol
33

44
#include <stdio.h>
5+
#include <cassert>
56
#include <rlbox/rlbox.hpp>
67
#include <rlbox/rlbox_noop_sandbox.hpp>
78
#include "mylib.h"
@@ -12,7 +13,8 @@ void hello_cb(rlbox_sandbox<rlbox_noop_sandbox>& _,
1213
tainted<const char*, rlbox_noop_sandbox> str) {
1314
auto checked_string =
1415
str.copy_and_verify_string([](std::unique_ptr<char[]> val) {
15-
return std::strlen(val.get()) < 1024 ? std::move(val) : nullptr;
16+
assert(val != nullptr && std::strlen(val.get()) < 1024);
17+
return std::move(val);
1618
});
1719
printf("hello_cb: %s\n", checked_string.get());
1820
}

examples/hello-world-noop/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define RLBOX_USE_STATIC_CALLS() rlbox_noop_sandbox_lookup_symbol
33

44
#include <stdio.h>
5+
#include <cassert>
56
#include "mylib.h"
67
#include "../../code/include/rlbox.hpp"
78
#include "../../code/include/rlbox_noop_sandbox.hpp"
@@ -12,7 +13,8 @@ void hello_cb(rlbox_sandbox<rlbox_noop_sandbox>& _,
1213
tainted<const char*, rlbox_noop_sandbox> str) {
1314
auto checked_string =
1415
str.copy_and_verify_string([](std::unique_ptr<char[]> val) {
15-
return std::strlen(val.get()) < 1024 ? std::move(val) : nullptr;
16+
assert(val != nullptr && std::strlen(val.get()) < 1024);
17+
return std::move(val);
1618
});
1719
printf("hello_cb: %s\n", checked_string.get());
1820
}

0 commit comments

Comments
 (0)