Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
dont allow unitinialized access
Browse files Browse the repository at this point in the history
fixes #13
  • Loading branch information
aep committed Mar 16, 2020
1 parent 680ad15 commit f6a0923
Show file tree
Hide file tree
Showing 28 changed files with 456 additions and 193 deletions.
3 changes: 1 addition & 2 deletions modules/io/src/lib.zz
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ export fn await(Async mut* self, err::Err+et mut*e, void *poll, void mut* user,
where safe(poll)
{
let mut tt = timeout(self, e,timeout_);
string::String+8 mut b;
b.clear();
string::String+8 mut b = {0};
if err::check(e) {return;}

poll_fn fp = (poll_fn)poll;
Expand Down
6 changes: 2 additions & 4 deletions modules/io/src/main.zz
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export fn main() -> int {
assert(t.valid());

for (;;) {
string::String+20 mut buf2;
buf2.clear();
string::String+20 mut buf2 = {0};

switch t.read(&e, &buf2) {
io::Result::Ready => {
Expand All @@ -45,8 +44,7 @@ export fn main() -> int {
}
e.abort();

string::String+2 mut buf;
buf.clear();
string::String+2 mut buf = {0};

switch i.read(&e, &buf) {
io::Result::Ready => {
Expand Down
4 changes: 2 additions & 2 deletions modules/pool/src/lib.zz
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export fn free(Pool mut *self, void * unsafe mut ptr_)
return;
}

u8 mut blocks;
usize mut startblock;
u8 mut blocks = 1;
usize mut startblock = 0;
unsafe {
ptr = ptr - 8;
ASAN_UNPOISON_MEMORY_REGION(ptr, 8);
Expand Down
10 changes: 10 additions & 0 deletions modules/string/src/lib.zz
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ export fn append_slice(String+tail mut * self) -> MutSlice
};
}

export fn new(String+tail mut * self)
model self->len == 0
model nullterm(self->mem)
{
c_string::memset(self->mem, 0, tail);
self->len = 0;

static_attest(nullterm(self->mem));
}

export fn clear(String+tail mut * self)
model self->len == 0
model nullterm(self->mem)
Expand Down
3 changes: 1 addition & 2 deletions modules/string/tests/format.zz
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ test blah {
}

export fn main() -> int {
string::String+10 mut s;
string::clear(&s);
string::String+10 mut s = {0};

string::append_cstr(&s, "hello");
string::format(&s, "%d%d%d%d", 2, 3, 66,9);
Expand Down
6 changes: 2 additions & 4 deletions modules/string/tests/split.zz
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ test test5 {

export fn main() -> int {

string::String+100 mut a;
string::clear(&a);
string::String+100 mut a = {0};
string::fgets(&a, stdin);


usize mut iterator = 0;
string::String+100 mut part;
string::clear(&part);
string::String+100 mut part = {0};
while (string::split(&a, ':', &iterator, &part)) {
printf(">%.*s<\n", (int)part.len, part.mem);
string::clear(&part);
Expand Down
6 changes: 2 additions & 4 deletions modules/string/tests/substr.zz
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ test t7{


export fn main() -> int {
string::String+20 mut sub;
string::clear(&sub);
string::String+20 mut sub = {0};

char mut * mut line = 0;
usize mut l = 0;
Expand All @@ -53,8 +52,7 @@ export fn main() -> int {
string::append_bytes(&sub, (u8*)line, (usize)nread -1);


string::String+20 mut s;
string::clear(&s);
string::String+20 mut s = {0};

nread = as<int>(getline(&line, &l, stdin));
if nread < 1 { return 1; }
Expand Down
4 changes: 2 additions & 2 deletions src/smt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ impl Solver {
self.checkpoint();
}

pub fn literal(&mut self, tmp: Symbol, val: u64, typ: Type) {
pub fn literal(&mut self, tmp: TemporalSymbol, val: u64, typ: Type) {

let smt_lhs = self.var(&(tmp,0));
let smt_lhs = self.var(&tmp);

match typ {
Type::Unsigned(size) | Type::Signed(size) => {
Expand Down
Loading

0 comments on commit f6a0923

Please sign in to comment.