File: fuzz_zlog_inputs.py

package info (click to toggle)
frr 10.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 77,024 kB
  • sloc: ansic: 687,126; python: 226,152; perl: 6,379; sh: 2,685; cpp: 1,883; makefile: 670; yacc: 397; lex: 363; lisp: 66; xml: 35; javascript: 8
file content (28 lines) | stat: -rw-r--r-- 705 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# SPDX-License-Identifier: GPL-2.0-or-later
# zlog fuzz-tester input generator
#
# Copyright (C) 2021  David Lamparter for NetDEF, Inc.

from itertools import chain
import struct

lengths = set([128])
# lengths = [[i, i + 1, i + 3, i - 1, i - 3] for i in lengths]
# lengths = set([i for i in chain(*lengths) if i >= 0])

dsts = [0, 1, 2, 3]
fmts = [0, 1, 2, 3]


def combo():
    for l0 in lengths:
        for l1 in lengths:
            for l2 in lengths:
                for fmt in fmts:
                    for dst in dsts:
                        yield (l0, l1, l2, fmt, dst)


for i, tup in enumerate(combo()):
    with open("input/i%d" % i, "wb") as fd:
        fd.write(struct.pack("HHHBB", *tup))