omega-harness
Agent skills for operating, encoding and communicating in Omega (.om) and the AIEN repositories
Brought by drakestapleton
omega-harness / examples / mistake_bound_input.om
| 1 | note mistake_bound_input: a bound is a trap, not a clamp. scan counts letters with bound 70; the 111 |
| 2 | note letters stand for outside input (a request line, a file, a database row): pass 71 traps 4, exit 104. |
| 3 | note The fix is bound_input_guard.om: stop below the bound, or check the length before the loop. |
| 4 | global b uchar 128 |
| 5 | fn scan e ulong to ulong |
| 6 | q = ulong 0 |
| 7 | while lt q e bound 70 |
| 8 | if ne get b q 65 |
| 9 | break |
| 10 | end |
| 11 | q = add q 1 |
| 12 | end |
| 13 | ret q |
| 14 | end |
| 15 | fn main to int |
| 16 | for i ulong 111 |
| 17 | put b i 65 |
| 18 | end |
| 19 | r = scan ulong 111 |
| 20 | if eq r 0 |
| 21 | ret 0 |
| 22 | end |
| 23 | ret 1 |
| 24 | end |