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 / om / tls / test / fuzz / fz_http.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note fz_http.om: fuzz target for the HTTP/1.1 message parser of seed/net/http.om in memory mode |
| 3 | note (hmemld), the mode seed/net/tests/parse.om uses, with the same caps (head 2048 bytes, 16 header |
| 4 | note fields, body 4096 bytes, chunk framing allowance 1024 bytes). |
| 5 | note Input: M message. M bit 0 and 1: 0 = response (hrsprd), 1 = response to HEAD, 2 or 3 = request |
| 6 | note (hreqrd, server role); then the decoded body (hbodyall), whatever framing the head chose. |
| 7 | |
| 8 | fn fz_hrun cs edit ulong 320 io edit uchar 65536 x view uchar * to long |
| 9 | aux = new uchar 65536 0 |
| 10 | md = and ulong get x 0 3 |
| 11 | role = ulong 0 |
| 12 | if ge md 2 |
| 13 | role = 1 |
| 14 | end |
| 15 | r = hinit cs io -1 role |
| 16 | if lt r 0 |
| 17 | ret r |
| 18 | end |
| 19 | r = hmemld cs io view part x 1 sub len x 1 |
| 20 | if lt r 0 |
| 21 | ret r |
| 22 | end |
| 23 | put cs HHEADMX 2048 |
| 24 | put cs HHMAX 16 |
| 25 | put cs HBCAP 4096 |
| 26 | put cs HFRMAX 1024 |
| 27 | if ge md 2 |
| 28 | r = hreqrd cs io |
| 29 | else |
| 30 | if eq md 1 |
| 31 | put cs HISHEAD 1 |
| 32 | end |
| 33 | r = hrsprd cs io |
| 34 | end |
| 35 | if le r 0 |
| 36 | ret r |
| 37 | end |
| 38 | ret hbodyall cs io part aux 0 65536 |
| 39 | end |
| 40 | |
| 41 | fn main to int |
| 42 | cs = new ulong 320 0 |
| 43 | io = new uchar 65536 0 |
| 44 | in = new uchar FZCAP 0 |
| 45 | n = fz_read in |
| 46 | if lt n 1 |
| 47 | ret 0 |
| 48 | end |
| 49 | r = fz_hrun cs io part in 0 n |
| 50 | ret 0 |
| 51 | end |