omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / qualification / security673 / path-consumer.om
| 1 | note Synthetic issue671 path and argread boundary consumer. Mode byte on stdin. |
| 2 | note Modes0-3 exercise fopen; modes4-6 exercise argread with the first argument. |
| 3 | global mode uchar 1 |
| 4 | global buf uchar 4096 |
| 5 | text ok "build/security673-native/path-ok" |
| 6 | text data "x" |
| 7 | fn main to int |
| 8 | if ne read 0 mode 0 1 1 |
| 9 | ret 90 |
| 10 | end |
| 11 | m = ulong get mode 0 |
| 12 | if eq m 0 |
| 13 | fd = fopen ok 0 len ok 577 384 |
| 14 | if lt fd 0 |
| 15 | ret 91 |
| 16 | end |
| 17 | r = write int fd data 0 1 |
| 18 | if ne r 1 |
| 19 | ret 92 |
| 20 | end |
| 21 | if ne fclose int fd 0 |
| 22 | ret 93 |
| 23 | end |
| 24 | ret 0 |
| 25 | end |
| 26 | if eq m 1 |
| 27 | for i ulong len ok |
| 28 | put buf i get ok i |
| 29 | end |
| 30 | put buf 5 0 |
| 31 | r = fopen buf 0 len ok 0 0 |
| 32 | ret 94 |
| 33 | end |
| 34 | if eq m 2 |
| 35 | for i ulong 4096 |
| 36 | put buf i 97 |
| 37 | end |
| 38 | r = fopen buf 0 4096 0 0 |
| 39 | ret 95 |
| 40 | end |
| 41 | if eq m 3 |
| 42 | r = fopen buf 0 0 0 0 |
| 43 | if lt r 0 |
| 44 | ret 0 |
| 45 | end |
| 46 | ret 96 |
| 47 | end |
| 48 | if eq m 4 |
| 49 | n = argread 1 buf 0 1 |
| 50 | if ne n neg long 105 |
| 51 | ret 97 |
| 52 | end |
| 53 | ret 0 |
| 54 | end |
| 55 | if eq m 5 |
| 56 | n = argread 99 buf 0 4 |
| 57 | ret 98 |
| 58 | end |
| 59 | if eq m 6 |
| 60 | n = argread 1 buf 0 len buf |
| 61 | if le n 0 |
| 62 | ret 99 |
| 63 | end |
| 64 | ret 0 |
| 65 | end |
| 66 | ret 98 |
| 67 | end |