interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / qualification / security673 / pkt-consumer.om

70 lines · 1170 bytes Raw Blame History
1note Synthetic issue #671 packed-list consumer. Hostile stdin bytes reach execprog unchanged.
2note With one decimal argument K, only the first K bytes are passed (truncation at each boundary).
3note A malformed packet traps 3 (exit 103) inside execprog; a valid one replaces this process.
4note Own exits: 90 usage or bad K, 91 read failure or input over 131071 bytes, 95 exec failed.
5global pkt uchar 131072
6global arg uchar 8
7fn rdall to long
8note Every pass but the last adds at least one byte to the 131072-byte buffer: 131073 passes bound it.
9n = ulong 0
10k = long 1
11while gt k 0 bound 131073
12if eq n len pkt
13ret -1
14end
15k = read 0 pkt n sub len pkt n
16if gt k 0
17n = add n ulong k
18end
19end
20if lt k 0
21ret k
22end
23ret long n
24end
25fn argk to long
26r = argread 1 arg 0 len arg
27if lt r 1
28ret -1
29end
30if gt r 5
31ret -1
32end
33v = ulong 0
34for i ulong ulong r
35c = get arg i
36if lt c 48
37ret -1
38end
39if gt c 57
40ret -1
41end
42v = add mul v 10 ulong sub c 48
43end
44ret long v
45end
46fn main to int
47if gt argcnt 2
48ret 90
49end
50t = rdall
51if lt t 0
52ret 91
53end
54k = ulong t
55if eq argcnt 2
56a = argk
57if lt a 0
58ret 90
59end
60if gt a t
61ret 90
62end
63k = ulong a
64end
65r = execprog pkt 0 k
66if ge r 0
67ret 96
68end
69ret 95
70end