Commit ac06c5ed authored by George Hotz's avatar George Hotz

add error checking on file open

parent 5af95462
......@@ -83,7 +83,8 @@ func GetHookedUnicorn(root string, ram map[uint32](uint32), callback func(int, u
oracle_hash, _ := mu.MemRead(0x30001000, 0x20)
hash := common.BytesToHash(oracle_hash)
key := fmt.Sprintf("%s/%s", root, hash)
value, _ := ioutil.ReadFile(key)
value, err := ioutil.ReadFile(key)
check(err)
tmp := []byte{0, 0, 0, 0}
binary.BigEndian.PutUint32(tmp, uint32(len(value)))
......@@ -179,7 +180,9 @@ func RunUnicorn(fn string, ram map[uint32](uint32), checkIO bool, callback func(
mu.MemWrite(0, dat)
// inputs
inputs, _ := ioutil.ReadFile(fmt.Sprintf("%s/input", root))
inputs, err := ioutil.ReadFile(fmt.Sprintf("%s/input", root))
check(err)
mu.MemWrite(0x30000000, inputs[0:0xc0])
// load into ram
......@@ -191,7 +194,8 @@ func RunUnicorn(fn string, ram map[uint32](uint32), checkIO bool, callback func(
mu.Start(0, 0x5ead0004)
if checkIO {
outputs, _ := ioutil.ReadFile(fmt.Sprintf("%s/output", root))
outputs, err := ioutil.ReadFile(fmt.Sprintf("%s/output", root))
check(err)
real := append([]byte{0x13, 0x37, 0xf0, 0x0d}, outputs...)
output, _ := mu.MemRead(0x30000800, 0x44)
if bytes.Compare(real, output) != 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