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 / resources / negative.om

104 lines · 2181 bytes Raw Blame History
1note Exact-once source mutator. stdin original module; stdout mutated module.
2note argv1=1..4 mutates ep_event for that event only;5 mutates rv_reserve rollback.
3note Compile emitted module with UNCHANGED checks.om and demo.om. Expected exits7/4.
4note Reject missing/duplicate pattern, oversized source and I/O errors normally.
5global source uchar 16384
6global needle uchar 256
7global params ulong 2
8global arg uchar 8
9text epfind "if or lt event 1 gt event 4\nret 1\nend\nret 0\nend\n"
10text rvfind "for d ulong 8\nif gt get q d rv_room s d\nret 3\nend\nend\n"
11text eppre "if or lt event 1 gt event 4\nret 1\nend\nif eq event "
12text eppost "\nput e 4 0\nend\nret 0\nend\n"
13text rvbad "for d ulong 8\nif gt get q d rv_room s d\nret 3\nend\nput s add rv_charge j d get q d\nend\n"
14fn choose mode ulong to void
15if eq mode 5
16put params 1 len rvfind
17for i ulong len rvfind
18put needle i get rvfind i
19end
20else
21put params 1 len epfind
22for i ulong len epfind
23put needle i get epfind i
24end
25end
26end
27fn matches at ulong to bool
28for i ulong get params 1
29if ne get source add at i get needle i
30ret false
31end
32end
33ret true
34end
35fn input to bool
36size = ulong 0
37while lt size len source bound 16384
38n = read 0 source size sub len source size
39if lt n 0
40ret false
41end
42if eq n 0
43put params 0 size
44ret true
45end
46size = add size ulong n
47end
48ret false
49end
50fn replacement mode ulong to bool
51if eq mode 5
52ret eq write 1 rvbad 0 len rvbad long len rvbad
53end
54if ne write 1 eppre 0 len eppre long len eppre
55ret false
56end
57if ne write 1 arg 0 1 1
58ret false
59end
60ret eq write 1 eppost 0 len eppost long len eppost
61end
62fn main to int
63if ne argcnt 2
64ret 2
65end
66if ne argread 1 arg 0 8 1
67ret 2
68end
69mode = ulong get arg 0
70if or lt mode 49 gt mode 53
71ret 2
72end
73mode = sub mode 48
74choose mode
75if not input
76ret 3
77end
78if lt get params 0 get params 1
79ret 4
80end
81count = ulong 0
82found = ulong 0
83for at ulong add sub get params 0 get params 1 1
84if matches at
85count = add count 1
86found = at
87end
88end
89if ne count 1
90ret 4
91end
92if ne write 1 source 0 found long found
93ret 5
94end
95if not replacement mode
96ret 5
97end
98start = add found get params 1
99size = sub get params 0 start
100if ne write 1 source start size long size
101ret 5
102end
103ret 0
104end