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 / om / tls / test / fuzz / fz_http.om

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