code wiki / (root) / nx_rw_ptrchain.nx

nx_rw_ptrchain.nx source

↩ module page · 17 lines · 561 B

1// nx_rw_ptrchain.nx -- TRAP WITNESS (pack-rules vet). Tactic under test: chained pointer 2// arithmetic `buf + a + b` used directly as an address (pack rule 10 says broken; hoist offset). 3// Exit 0 iff the chained form addresses the correct byte. 4// license_tier: ORIGINAL 5import "nx_syscalls.nx" 6 7func main(argc: i64, argv: *i64) -> i64 { 8 let buf: *u8 = sys_mmap(64) as *u8 9 let a: i64 = 3 10 let b: i64 = 4 11 buf[7] = 42 as u8 12 let p2: *u8 = buf + a + b 13 let v: i64 = p2[0] as i64 14 if v == 42 { sys_exit(0) } 15 sys_exit(1) 16 return 0 17}