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 / branch-mutate.om
| 1 | note Exact-source qualification transform: argv1 picks one exact-once substitution in stdin, written to stdout. |
| 2 | note Mode0 renames the real main and appends a probe main that calls the real bdisp and emit. Mode1 weakens |
| 3 | note the forward limit by two instructions; mode2 makes close_range unavailable; mode3 admits 21-digit numbers; |
| 4 | note mode4 and mode5 bypass the exec filter and fence words; mode6 weakens the backward limit by two; mode7 |
| 5 | note removes the range test (alignment kept). Modes compose: mode7 then mode0 probes the range-free encoder. |
| 6 | note No transformed artifact is a production compiler. |
| 7 | global src uchar 1048576 |
| 8 | global used ulong 1 |
| 9 | global rlen ulong 1 |
| 10 | global mode uchar 8 |
| 11 | global needle uchar 64 |
| 12 | global repl uchar 64 |
| 13 | text entry "fn main to int" |
| 14 | text renamed "fn prev to int" |
| 15 | text fwd "gt diff sub span 4" |
| 16 | text fwdweak "gt diff add span 4" |
| 17 | text bwd "lt diff sub ulong 0 span" |
| 18 | text bwdweak "lt diff sub ulong 0 add span 8" |
| 19 | text range "if and gt diff sub span 4 lt diff sub ulong 0 span" |
| 20 | text norange "if false" |
| 21 | text seal "hsys 436" |
| 22 | text noseal "hsys 999" |
| 23 | text digits "if gt ndig 20" |
| 24 | text longer "if gt ndig 21" |
| 25 | text filter "hsys 277" |
| 26 | text fence "hsys 446" |
| 27 | text bypass "hsys 172" |
| 28 | text probe "\nfn main to int\nn = read 0 msg 0 1\nif ne n 1\nret 90\nend\nm = get msg 0\nif ge m 18\nret 90\nend\nif ge m 16\na_init\nput oc 0 8388604\nif eq m 17\nput oc 0 134217728\nend\nemit 0\nif eq m 17\nret 81\nend\nret 0\nend\na = ulong 0\nt = ulong 0\ne = ulong 0\nwd = ulong 19\nif ne and m 4 0\nwd = ulong 26\nend\nif eq m 0\nt = ulong 1048572\ne = ulong 262143\nend\nif eq m 1\na = ulong 1048576\ne = ulong 262144\nend\nif eq m 2\na = ulong 1024\ne = ulong 524032\nend\nif eq m 3\na = ulong 1028\ne = ulong 524031\nend\nif eq m 4\nt = ulong 134217724\ne = ulong 33554431\nend\nif eq m 5\na = ulong 134217728\ne = ulong 33554432\nend\nif eq m 6\na = ulong 1024\ne = ulong 67108608\nend\nif eq m 7\na = ulong 1028\ne = ulong 67108607\nend\nif eq m 8\nt = ulong 1048576\nend\nif eq m 9\na = ulong 1048580\nend\nif eq m 10\nt = ulong 2\nend\nif eq m 11\na = ulong 2\nend\nif eq m 12\nt = ulong 134217728\nend\nif eq m 13\na = ulong 134217732\nend\nif eq m 14\nt = ulong 2\nend\nif eq m 15\na = ulong 2\nend\nv = bdisp a t wd\nif ge m 8\nret 81\nend\nif ne v e\nret 82\nend\nret 0\nend\n" |
| 29 | fn matches i ulong to bool |
| 30 | for j ulong get used 0 |
| 31 | if ne get src add i j get needle j |
| 32 | ret false |
| 33 | end |
| 34 | end |
| 35 | ret true |
| 36 | end |
| 37 | fn srcout p ulong n ulong to void |
| 38 | while lt p n |
| 39 | r = write 1 src p sub n p |
| 40 | if le r 0 |
| 41 | exit 94 |
| 42 | end |
| 43 | p = add p ulong r |
| 44 | end |
| 45 | end |
| 46 | fn replout to void |
| 47 | p = ulong 0 |
| 48 | while lt p get rlen 0 |
| 49 | r = write 1 repl p sub get rlen 0 p |
| 50 | if le r 0 |
| 51 | exit 94 |
| 52 | end |
| 53 | p = add p ulong r |
| 54 | end |
| 55 | end |
| 56 | fn probeout to void |
| 57 | p = ulong 0 |
| 58 | while lt p len probe |
| 59 | r = write 1 probe p sub len probe p |
| 60 | if le r 0 |
| 61 | exit 94 |
| 62 | end |
| 63 | p = add p ulong r |
| 64 | end |
| 65 | end |
| 66 | fn main to int |
| 67 | if ne argcnt 2 |
| 68 | ret 90 |
| 69 | end |
| 70 | r = argread 1 mode 0 len mode |
| 71 | if ne r 1 |
| 72 | ret 90 |
| 73 | end |
| 74 | m = get mode 0 |
| 75 | if or lt m 48 gt m 55 |
| 76 | ret 90 |
| 77 | end |
| 78 | if eq m 48 |
| 79 | put used 0 len entry |
| 80 | put rlen 0 len renamed |
| 81 | for i ulong len entry |
| 82 | put needle i get entry i |
| 83 | put repl i get renamed i |
| 84 | end |
| 85 | end |
| 86 | if eq m 49 |
| 87 | put used 0 len fwd |
| 88 | put rlen 0 len fwdweak |
| 89 | for i ulong len fwd |
| 90 | put needle i get fwd i |
| 91 | end |
| 92 | for i ulong len fwdweak |
| 93 | put repl i get fwdweak i |
| 94 | end |
| 95 | end |
| 96 | if eq m 50 |
| 97 | put used 0 len seal |
| 98 | put rlen 0 len noseal |
| 99 | for i ulong len seal |
| 100 | put needle i get seal i |
| 101 | put repl i get noseal i |
| 102 | end |
| 103 | end |
| 104 | if eq m 51 |
| 105 | put used 0 len digits |
| 106 | put rlen 0 len longer |
| 107 | for i ulong len digits |
| 108 | put needle i get digits i |
| 109 | put repl i get longer i |
| 110 | end |
| 111 | end |
| 112 | if eq m 52 |
| 113 | put used 0 len filter |
| 114 | put rlen 0 len bypass |
| 115 | for i ulong len filter |
| 116 | put needle i get filter i |
| 117 | put repl i get bypass i |
| 118 | end |
| 119 | end |
| 120 | if eq m 53 |
| 121 | put used 0 len fence |
| 122 | put rlen 0 len bypass |
| 123 | for i ulong len fence |
| 124 | put needle i get fence i |
| 125 | put repl i get bypass i |
| 126 | end |
| 127 | end |
| 128 | if eq m 54 |
| 129 | put used 0 len bwd |
| 130 | put rlen 0 len bwdweak |
| 131 | for i ulong len bwd |
| 132 | put needle i get bwd i |
| 133 | end |
| 134 | for i ulong len bwdweak |
| 135 | put repl i get bwdweak i |
| 136 | end |
| 137 | end |
| 138 | if eq m 55 |
| 139 | put used 0 len range |
| 140 | put rlen 0 len norange |
| 141 | for i ulong len range |
| 142 | put needle i get range i |
| 143 | end |
| 144 | for i ulong len norange |
| 145 | put repl i get norange i |
| 146 | end |
| 147 | end |
| 148 | n = ulong 0 |
| 149 | go = true |
| 150 | while go |
| 151 | if eq n len src |
| 152 | ret 91 |
| 153 | end |
| 154 | r = read 0 src n sub len src n |
| 155 | if lt r 0 |
| 156 | ret 92 |
| 157 | end |
| 158 | if eq r 0 |
| 159 | go = false |
| 160 | else |
| 161 | n = add n ulong r |
| 162 | end |
| 163 | end |
| 164 | found = ulong 0 |
| 165 | at = ulong 0 |
| 166 | for i ulong n |
| 167 | if le get used 0 sub n i |
| 168 | if matches i |
| 169 | found = add found 1 |
| 170 | at = i |
| 171 | end |
| 172 | end |
| 173 | end |
| 174 | if ne found 1 |
| 175 | ret 93 |
| 176 | end |
| 177 | srcout 0 at |
| 178 | replout |
| 179 | srcout add at get used 0 n |
| 180 | if eq m 48 |
| 181 | probeout |
| 182 | end |
| 183 | ret 0 |
| 184 | end |